- Explain how the shell relates to the keyboard, screen, OS, and user programs
- Explain when and why to use command-line interfaces instead of GUIs
- Explain the difference between a file and a directory
- Translate between absolute and relative paths
- Use options and arguments to change command behavior
- Use tab completion effectively
- WSL (Windows users)Windows Subsystem for Linux
- Git for WindowsAlternative for Windows users
- shell-lesson-data.zipWorkshop dataset — download and unzip to your Desktop
- Carpentries lessonOfficial lesson page we follow today
Open your terminal. You should see a prompt — this means the shell is ready for input.
$ | # The prompt — hey, it's working!
$ ls # List files in the current directory (your home directory)
$ pwd # Print working directory — where are you?
If you're using WSL, navigate to your Windows files with: cd /mnt/c/<your username>
cd (change directory) is the most-used command you'll learn today. Master it.
$ cd / # Go to the root of the filesystem
$ cd # Shortcut: go back to your home directory
$ cd ~/ # Same thing — ~ always means home
$ cd Desktop/shell-lesson-data/exercise-data
Press Tab after typing the first few letters of a path. The shell completes it for you. If nothing happens, press Tab twice to see all options. Try misspelling something to see what the error looks like: cd Desktap/shell-lesson-data
Moving Up and Around
$ cd .. # Move up one directory level
$ cd exercise-data # Move into a subdirectory
$ cd - # Go back to the previous directory
What directory will this move you to? cd ../..
Come up with two ways to navigate back to the directory containing the workshop data.
Use the up/down arrow keys to scroll through your command history — you don't have to retype commands.
Flags modify how a command behaves. They start with a dash -.
$ ls -l # Long format — shows permissions, size, date
$ ls -lF # Adds "/" after directory names
$ ls -lah # Long format, all files (including hidden), human-readable sizes
$ clear # Clear the terminal screen
$ man ls # Read the manual for ls — press q to exit
Use the manual (man ls) to determine how to add color to the output of ls. Answer: ls -G
The real power of Unix comes from combining commands. The pipe | sends the output of one command into the input of another.
$ ls -F | grep \/ > directories.txt
# | pipes output into grep (a search tool)
# grep \/ searches for "/" (i.e., directories)
# > writes the output to a new file called directories.txt
Viewing File Contents
$ head directories.txt # Show first 10 lines
$ tail directories.txt # Show last 10 lines
$ less directories.txt # Scroll through the file (press q to exit)
$ more directories.txt # Similar to less
Wildcards
The wildcard * matches any number of characters. Navigate to ~/Desktop/shell-lesson-data/north-pacific-gyre and try:
$ wc -l NENE01736A.txt # Count lines in one file
$ wc -l *.txt # Count lines in ALL .txt files
Absolute vs. Relative Paths
$ cd ~/Desktop/shell-lesson-data
$ head -5 exercise-data/directories.txt # relative path — works
$ head -5 directories.txt # why doesn't this work?
$ head -5 ~/Desktop/shell-lesson-data/exercise-data/directories.txt # absolute path
$ rm directories.txt # remove the file when done
Pipelines can be hard to read at first. Use AI to break them down. Try this prompt:
Then try modifying the command — ask AI what would happen if you changed \/ to something else, or used >> instead of >.
Make sure you have shell-lesson-data on your Desktop. We'll re-download it fresh at the start of Day 2.