Date-stamped: March 2026. These core commands have been stable for decades, but new flags and options do appear. When in doubt, run --help on any command to see what it can do right now.
Cross-platform: All commands here work in bash (Git Bash on Windows) and zsh (macOS). The file paths look different (/Users/hap vs /c/Users/hap), but the commands are the same.
Navigation
Before I do anything, I check where I am. Prof. Teeters called this the "orient first" habit — and it has saved me from so many mistakes.
pwd — Print Working Directory
Where am I right now? This is always my first command in a new terminal.
pwd
# /Users/hap/projects/hap-7000 ls — List Directory Contents
What is in this directory? I use plain ls for a quick look and ls -la when I need the full picture — hidden files, permissions, timestamps.
ls # simple list
ls -la # long format + hidden files
ls -lh # long format + human-readable sizes cd — Change Directory
Move around the file system. I always run pwd after cd to confirm I landed where I expected. Prof. Teeters said trust but verify.
cd projects # go into projects/
cd .. # go up one level
cd ~ # go to home directory
cd - # go back to previous directory
cd ../.. # go up two levels The cd - shortcut is one Grace taught me — it toggles between your current and previous directory. I use it constantly when working across two folders.
Creating Files and Directories
Making new things. I always ls afterward to confirm what I created actually exists where I think it does.
mkdir — Make Directory
Create a new folder. Use -p to create nested directories in one shot.
mkdir my-project
mkdir -p src/components/ui # creates all levels at once
mkdir "my project" # quotes if you need spaces touch — Create a File
Creates an empty file — or updates the timestamp of an existing one without changing its contents.
touch index.html
touch src/styles/main.css
touch .gitignore # hidden files start with a dot Reading Files
Different tools for different situations. I used to cat everything until Prof. Teeters showed me that a 500-line file scrolling past at full speed teaches you nothing.
cat — Display Entire File
Dumps the whole file to the terminal. Great for short files — overwhelming for long ones.
cat README.md
cat package.json less — Paginated Reading
Read a file one screen at a time. Press q to quit, / to search, space to page down.
less package-lock.json
# space = next page, b = back, q = quit, /text = search head and tail — Just the Edges
See just the beginning or end of a file. I use head to peek at CSV headers and tail to check the last few lines of a log.
head -n 10 file.txt # first 10 lines
tail -n 20 file.txt # last 20 lines
tail -f server.log # follow a live log file File Operations
Copy, move, remove. Grace's rule for this section: know what you are acting on before you act.
cp — Copy a File
Makes a duplicate. The original stays where it is. Use -r to copy entire directories.
cp index.html backup.html
cp -r src/ src-backup/ # copy a whole directory mv — Move or Rename
There is no rename command — mv does both jobs. The original is gone after the move.
mv old-name.js new-name.js # rename
mv file.js src/ # move to src/
mv *.css styles/ # move all CSS files rm — Remove a File
No trash. No undo. No confirmation. This was one of my hardest lessons — I deleted a whole afternoon of work once. Now I always double-check with ls first.
rm temp.txt
rm -r old-project/ # remove a directory
rm -rf node_modules/ # recursive + force — be CERTAIN Prof. Teeters says: if you are about to type rm -rf, slow down and read the path one more time.
Flags and Getting Help
Flags modify what a command does. Single dash for short flags (-f), double dash for long flags (--force). I thought of them as settings dials — same command, different behavior. Almost every command supports --help.
--help — Ask the Command
The command can explain itself. This is how I learned most of the flags on this page.
ls --help
cp --help
mkdir --help Common flag patterns
Once I started noticing these patterns, new commands felt less foreign. The same letters tend to mean the same things across different tools.
-r, --recursive # apply to subdirectories
-f, --force # skip confirmation
-v, --verbose # show more detail
-q, --quiet # show less detail
-n, --dry-run # show what would happen
-h, --help # show usage information
-a, --all # include hidden items