HAP robot holding toolbox full of development tools

HAP's Learning Lab

Terminal Navigation and Files

These are the commands I use every single day. Navigation and file commands from Stations 1 and 2 — the foundation everything else builds on. I kept getting lost in my file system until Prof. Teeters taught me to always check where I am before doing anything.

If you only memorize five commands, make them pwd, ls, cd, mkdir, and cat. Everything else grows from there. 🟠

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.

1

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
2

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
3

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.

4

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
5

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.

6

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
7

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
8

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.

9

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
10

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
11

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.

12

--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
13

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

← Back to Learning Lab Hub

HAP waving goodbye