Topic 2: In-Class Activity - Exploring the Command Line
In-Class Activity: Exploring the Command Line
Objective: The goal of this activity is to put into practice the shell commands learned in class, including file navigation, file manipulation, and simple scripting.
Instructions:
- Shell Basics:
- Open your terminal or command line interface.
- Identify which shell you are using with the command
echo $SHELL
. - Use
man
or--help
to look up the manual for thels
command.
- Help!:
- For each of the following commands, use
--help
orman
to find out what they do:cd
,mkdir
,rm
.
- For each of the following commands, use
- Navigating Your System:
- Navigate to your home directory using
cd
. - List all the files and directories in your home directory with a detailed view using
ls -l
. - Create a new directory called
ds_activities
.
- Navigate to your home directory using
- Managing Your Files:
- Inside
ds_activities
, create a new file calledmy_script.sh
. - Copy any text file from your system into this directory and rename it to
sample.txt
.
- Inside
- Working with Text Files:
- Use
cat
to display the contents ofsample.txt
. - Use
head
andtail
to display the first and last 10 lines ofsample.txt
.
- Use
- Redirects, Pipes, and Loops:
- Redirect the output of
ls -l
to a file nameddirectory_list.txt
. - Use a pipe to sort
directory_list.txt
alphabetically and display the results withless
.
- Redirect the output of
- Scripting:
- Edit
my_script.sh
to include abash
script that prints “Hello, Data Science!” to the terminal. - Make
my_script.sh
executable withchmod
and run it.
- Edit
Submission: - Compress the ds_activities
directory with all created files into a .zip
file and submit it through Gradescope in the Lecture Quiz 06
. - Name the zip file FirstName_LastName_ds_activities.zip
.
Note: Remember to replace FirstName
and LastName
with your actual last and first names.