The terminal, shell, and Unix
The skill that pays compound interest forever. Pipes, processes, find, grep, ssh, tmux — the toolkit that turns a CS student into someone who can move.
Prerequisites
00.2
Stack
zsh or bashcoreutilsripgrep, fd, fzf, jq, bat, tmux, ssh
By the end of this module
- Move comfortably around a Unix filesystem and process tree without thinking about it.
- Compose pipelines that solve real problems in one line.
- SSH into a remote machine and stay productive there with tmux.
- Use ripgrep, fd, fzf, jq, and bat as defaults — not occasionally.
The terminal is the skill with the strongest compounding curve in this whole curriculum. Every other tool — your editor, your version control, your remote server, your Docker container, your AI agent — sits on top of a shell. Get fluent in the shell and everything above it gets faster forever. Stay slow at the shell and you will spend your whole career fighting friction you don’t even notice.
Most students avoid the shell because it feels archaic. The commands are short, opaque, sometimes hostile. The reflex is to reach for a GUI instead. That reflex is the trap. The shell is short and opaque because it was designed to be composed, and composition is the superpower. Once you can build a four-stage pipeline that finds something, transforms it, filters it, and writes it to a file in a single line — without breaking a sweat — you’ll feel the difference.
The opinionated take for this module: do not learn vim deeply yet. The vim cult will tell you it’s the most important tool in the shell. They are wrong, for you, right now. Get fluent in the shell first, modal editor second. You will get there. Just not this week.
Set up
Most of this you already have from 00.2. Confirm:
which zsh tmux git ssh ripgrep fd fzf jq bat
# all should print a path. If any are missing:
brew install zsh tmux git ripgrep fd fzf jq bat # macOS
sudo apt install zsh tmux git ripgrep fd-find fzf jq bat # Debian/Ubuntu
Then run the fzf install script that comes with it:
$(brew --prefix)/opt/fzf/install # macOS
/usr/share/doc/fzf/examples/install # Debian/Ubuntu
That sets up Ctrl-R for fuzzy history search, which alone is worth the module.
Read these first
Four sources, in this order, then stop.
- MIT — Missing Semester, lectures 1–3, 5. link · 4 hrs total · the canonical course on tooling.
- Julia Evans — Bash Scripting Cheat Sheet and Pocket Guide to Debugging. zines · 1 hr · the friendliest reference around.
- Greg Wooledge — Bash Pitfalls. link · 30 min · what not to do, by someone who has answered every shell question on IRC for 20 years.
- The Art of Command Line. repo · 30 min · the dense reference. Bookmark it.
Skip the “10 cool Linux tricks” YouTube content. The above will give you everything they cover and more.
Mental model: everything is a stream
The whole point of Unix is that programs read text from stdin, do one thing, and write text to stdout. You compose programs by piping output of one into input of the next. Internalize this and the rest is just learning the verbs.
A pipeline is: command1 | command2 | command3
└── stdout flows ──┘
Three streams to know:
| Stream | Number | Default |
|---|---|---|
| stdin | 0 | keyboard |
| stdout | 1 | terminal |
| stderr | 2 | terminal |
Redirection:
cmd > out.txt # stdout to file (overwrite)
cmd >> out.txt # stdout to file (append)
cmd 2> err.txt # stderr to file
cmd > all.txt 2>&1 # both streams to one file
cmd < input.txt # read stdin from file
cmd1 | cmd2 # cmd1's stdout becomes cmd2's stdin
Once that clicks, every shell trick is a variation on it.
The verbs you actually use
You do not need to memorize 200 commands. You need ~25, fluently.
| Verb | What it does | Modern replacement |
|---|---|---|
cd, pwd, ls | Navigate | — |
mv, cp, rm, mkdir | Manage files | — |
cat, less, head, tail | Read files | bat for cat with syntax highlighting |
grep | Search inside files | rg (ripgrep) — order-of-magnitude faster |
find | Find files by name | fd — friendlier syntax, faster |
cut, sort, uniq, wc | Text shaping | — |
awk, sed | Bigger text transforms | learn the 5% you need, defer the rest |
xargs | Pipe args to a command | xargs -I{} cmd {} is the move |
ps, top, htop, kill | Processes | htop is the sane top |
df, du, free | Disk and memory | du -sh * daily |
tar, gzip, unzip, zip | Archives | — |
curl, wget | HTTP from the shell | — |
jq | Process JSON | non-negotiable in 2026 |
ssh, scp, rsync | Remote work | rsync over scp, always |
tmux | Persistent sessions | — |
chmod, chown | Permissions | — |
You’ll learn each by using it on real problems, not by reading the man page cover to cover.
The shell cookbook
Fifteen one-liners every CS student should be able to write without looking up. If you can read each one and explain what it does, you have a working shell.
# 1. Find all Python files modified in the last 7 days
fd -e py --changed-within 7d
# 2. Grep recursively for a string, case-insensitive, only in tracked files
rg -i "TODO" --no-ignore-vcs
# 3. Count lines of code, by extension, in a project
fd -e py -e ts --exec wc -l | sort -n
# 4. Find the 10 largest files in the current tree
du -ah . | sort -rh | head -n 10
# 5. Show all processes using port 3000
lsof -i :3000
# 6. Kill all processes matching a pattern
pkill -f "old-server"
# 7. Pretty-print a JSON file
jq . file.json
# 8. From an HTTP response, extract one field
curl -s https://api.github.com/users/torvalds | jq -r '.public_repos'
# 9. Replace text across many files (preview, then run)
rg -l "old_name" | xargs sed -i.bak 's/old_name/new_name/g'
# 10. Run a command in every git-tracked subdirectory
git ls-files -z | xargs -0 -n1 dirname | sort -u | while read d; do
echo "==> $d"; (cd "$d" && some-command); done
# 11. Watch a command, repeat every 2s
watch -n 2 "ls -la /tmp"
# 12. Tail a log file but follow rotation
tail -F /var/log/system.log
# 13. SSH into a server and run one command
ssh user@server "df -h /"
# 14. Sync a directory up to a server, preserving permissions
rsync -avz --delete ./build/ user@server:/var/www/site/
# 15. Find what's eating your disk
du -sh ./* 2>/dev/null | sort -rh | head -20
Practice each on a real project. The first time it’ll take you 90 seconds with the man page. The fifth time it’ll be muscle memory.
Processes and jobs
A process is a running program. Your shell is a process. Every command you run is a child process. Understanding this saves you from the weekly “why is my port already in use” crisis.
# What's running?
ps aux | head
htop
# What's using port 8080?
lsof -i :8080
# Kill by PID
kill 12345
# Kill harder
kill -9 12345
# Kill by name pattern
pkill -f "python.*manage.py runserver"
Background jobs in the shell:
long-running-command & # run in background
jobs # list jobs
fg # bring most recent to foreground
fg %2 # bring job 2 to foreground
ctrl-z # suspend foreground job
bg # resume in background
disown %1 # detach from shell (survives logout)
The trick most students don’t know: ctrl-z then bg lets you “oh wait I forgot to background that” without restarting.
SSH and ssh-agent
You will SSH into something — a VM, a cloud server, a friend’s computer — by week three of any real project. Set this up once.
# Generate a key (you did this in 00.2; if not:)
ssh-keygen -t ed25519 -C "you@example.com"
# Start the agent and add your key (so you don't retype the passphrase)
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
# A useful ~/.ssh/config:
cat >> ~/.ssh/config <<'EOF'
Host vps
HostName 203.0.113.10
User deploy
IdentityFile ~/.ssh/id_ed25519
ForwardAgent yes
EOF
chmod 600 ~/.ssh/config
# Now you can just:
ssh vps
Pro tip: ssh -A (or ForwardAgent yes in config) means your local key works from the remote machine to a third one — useful when you git clone on a server.
tmux: the trick that pays for itself
The single biggest “wait, why didn’t anyone show me this earlier” tool in the shell. tmux gives you persistent sessions: you start work, your laptop dies, your SSH connection drops, your work is still running on the server, you reattach and pick up.
# Start a named session
tmux new -s work
# Inside tmux:
ctrl-b c # new window
ctrl-b 0,1,2 # switch to window N
ctrl-b | # split pane vertical (with config from 00.2)
ctrl-b - # split pane horizontal
ctrl-b arrow # move between panes
ctrl-b z # toggle pane zoom
ctrl-b d # detach (work keeps running)
# From outside:
tmux ls # list sessions
tmux attach -t work # reattach
tmux kill-session -t work
That’s enough tmux for the next year. Don’t add a 40-line config or theme it. Use it.
fzf: the fuzzy finder you’ll use daily
After install, three keys you’ll use every day:
| Keybind | What it does |
|---|---|
Ctrl-R | Fuzzy search through shell history |
Ctrl-T | Fuzzy file picker — pastes a path into the current command |
Alt-C | Fuzzy cd into a subdirectory |
Once you’ve used Ctrl-R for a week, going back to up-arrow-spam feels like typing in mittens.
Why not vim, yet
You are going to hear a lot of “every real engineer uses vim.” The honest version: every senior engineer uses an editor they’re fluent in. For some, that’s vim. For most working engineers in 2026, that’s VS Code or Cursor. Vim has a ferocious learning curve and a real productivity peak — but the curve takes months to climb, and during those months you are slower, not faster.
The realistic plan: learn enough vim to edit a file over SSH (i insert, Esc, :wq, dd delete line, /foo search, n next match, :e file open). Treat it like learning enough Spanish to order food. Come back to it deeply in year two if you want.
Going deeper
When you have specific questions, in this order:
- The Linux Programming Interface — Michael Kerrisk. book · the encyclopedia. You will not read it cover to cover, you will reach for it for ten years.
- bash(1) and zsh(1) man pages. Once. Skim, don’t memorize.
- Bash Pitfalls. link · revisit periodically. Each time you’ll catch a bug you’ve written.
- Advanced Programming in the UNIX Environment — Stevens & Rago. book · for the day you’re writing systems code in C.
Checkpoints
If any one wobbles, the corresponding section above is what to reread.
- Explain stdin/stdout/stderr in your own words. Why is
cmd > out.txt 2>&1different fromcmd > out.txt? - Walk through five of the cookbook one-liners from memory, explaining what each does.
- What does
Ctrl-Rdo, and why is it the best 30 seconds you can spend on your shell setup? - What does tmux give you that a normal shell doesn’t? Name two situations where it saves you.
- Why is “learn vim deeply right now” the wrong move for most students at this stage?
If you can answer all five and the cookbook one-liners flow without lookup, you’ve earned 01.2. Next: 01.3 — Git and GitHub, properly. Now that you can move around a system, you need to stop fearing your version control.