The Terminal: Your First 20 Commands and Why It Still Matters
⚠️ Version note: these commands work in macOS Terminal and Linux as written. On Windows, use WSL, Git Bash, or the mostly-compatible PowerShell — the concepts are identical, a few command names differ (noted where they do). Last checked: 24 July 2026.
The scary black window is just a conversation
Most people meet the terminal as the thing hackers use in films, or the thing a tutorial told them to paste something into, hoping nothing broke. Both framings make it feel dangerous and arbitrary.
It's neither. The terminal is a conversation with your computer where you type instead of click, and once you see the grammar it's calmer and more precise than clicking, not less. Every command has the same shape:
command what to do
-flags how to do it
arguments what to do it toThat's it. ls -l Documents is "list, in long form, the Documents folder." Verb, adverb, object.
Once you hear that sentence structure, the twenty commands below are just vocabulary.
Why bother when the mouse works? Three real reasons, not nostalgia: some things are only possible here (bulk operations, automation, remote servers), some are ten times faster (rename 200 files at once), and nearly every technical tool — Git, Python, deployment, package managers — assumes you have a terminal open. It's the floor the rest of the technical pillar stands on.
What you'll have at the end
- A working mental model of where you are and how to move
- 20 commands covering the real daily jobs
- Actual work done: files organised, bulk-renamed, and searched
- The safety habits that stop the terminal biting you
Open it and find out where you are (5 min)
Open it: macOS — Terminal (⌘-Space, type Terminal). Linux — Ctrl-Alt-T. Windows — install WSL or
open Git Bash.
You'll see a prompt ending in $. It's waiting. Type, press Enter, it acts.
The single most important idea: you are always somewhere. The terminal has a "current folder" at all times, and commands act there unless you say otherwise. Three commands to orient:
pwd print working directory — WHERE AM I
ls list — WHAT'S HERE
whoami WHO AM I (which user)Type pwd. That path is your current location. Everything you do happens relative to it until you
move. Ninety per cent of "the command didn't work" is being in the wrong folder — when confused,
pwd and ls first, always.
✅ Check: you ran pwd and ls and can say, in words, where you currently are and what's there.
Move around (8 min)
cd Documents change directory — go into Documents
cd .. go UP one level (.. means "parent")
cd ~ go home (~ is your home folder)
cd also goes home
cd - go back to where you just were
ls -a list ALL, including hidden files (names starting with .)
ls -l long form: permissions, size, dateTwo ideas that unlock the rest:
.means here,..means up one.cd ../..goes up two levels. This is how you navigate without a map.- Tab completes. Type
cd Docand press Tab — it finishesDocuments/. This is not a nicety; it's how people actually work, and it prevents typos. Use it constantly.
Absolute vs relative paths:
/Users/you/Documents/report.txt absolute — from the root, works anywhere
Documents/report.txt relative — from where you are now✅ Check: you moved into a folder, went up, went home, and used Tab to complete a name.
Look at things without opening them (6 min)
cat file.txt dump the whole file to the screen
less file.txt page through a long file (q to quit, / to search)
head file.txt first 10 lines
tail file.txt last 10 lines
tail -f log.txt follow a file live as it grows (Ctrl-C to stop)
wc -l file.txt count the linesless is the one to remember for anything long: arrows to scroll, /word to search, q to quit.
cat is fine for short files and terrible for long ones (it floods the screen).
✅ Check: you've viewed a file with less, searched inside it, and quit cleanly with q.
Create, copy, move, delete (10 min)
Here's where the terminal earns its place — and where you need to be careful.
mkdir projects make a folder
mkdir -p a/b/c make nested folders in one go
touch notes.txt create an empty file (or update its timestamp)
cp file.txt backup.txt copy
cp -r folder/ copy/ copy a folder (-r = recursive, for folders)
mv old.txt new.txt RENAME (move to a new name)
mv file.txt Documents/ MOVE (same command — moving and renaming are one thing)
rm file.txt DELETE
rm -r folder/ delete a folder and everything in itThree things worth internalising:
mvis both rename and move. Renaming is just moving to a new name in the same folder. One command, two uses.touch+mkdirare how you scaffold a project structure in seconds instead of clicking through New Folder menus.
⚠️
rmdoes not go to a Trash. It is immediate and permanent. There is no undo. This is the one genuinely dangerous command, and two habits keep it safe:
lsthe thing before yourmit. Confirm you're deleting what you think.- Never, ever run
rm -rfon a path you haven't triple-checked — especially with*or a leading/.rm -rf /and similar are the famous computer-destroying commands, and they destroy becausermobeys instantly and completely. When a command online containsrm -rf, understand every character before running it.
✅ Check: you made a nested folder, created a file in it, copied it, renamed the copy, and deleted
the copy — checking with ls before the rm.
The two ideas that make it powerful (12 min)
Everything so far is convenience. These two turn the terminal into something the mouse can't do.
Wildcards — act on many things at once
ls *.txt everything ending in .txt
rm *.tmp delete all .tmp files (ls them first!)
cp *.jpg photos/ copy every jpg into photos
mv IMG_* 2026/ move everything starting with IMG_* means "anything". This is the bulk power: rename, move or process 200 files with one line
instead of 200 clicks.
Pipes — connect commands together
The deepest idea in the shell: the output of one command becomes the input of the next, joined by |.
ls | wc -l count how many things are in this folder
cat log.txt | grep "error" show only lines containing "error"
history | grep git find every git command you've ever run
ls -l | grep ".pdf" list only the PDFs, in detailEach command does one small thing well; pipes combine them into exactly the tool you need. This is the whole philosophy of the command line — small sharp tools, composed on the spot.
grep — find text anywhere
grep "budget" notes.txt lines containing "budget"
grep -r "TODO" . search EVERY file under here for TODO
grep -i "error" log.txt case-insensitive
grep -c "warning" log.txt just count the matchesgrep -r "something" . — search every file in the current folder and below — is one of the most
useful commands you will ever learn. It finds a word across a hundred files in a second.
✅ Check: you've used a wildcard to act on several files at once, and one pipe that combines two commands.
Not getting stuck, and getting help (6 min)
Ctrl-C stop the current command / get me out of here
Ctrl-L clear the screen (or: clear)
q quit a full-screen viewer (less, man)
↑ / ↓ scroll through previous commands
man ls the manual for any command (q to quit)
ls --help quicker summary of a command's options- Ctrl-C is your escape hatch. Command running too long, or stuck, or you changed your mind — Ctrl-C. Learn it before anything else.
- Up-arrow recalls your last commands. You rarely retype; you press up and edit.
man commandwhen you forget the flags. Every command documents itself. The-linls -l?man lstells you, along with everything else.
✅ Check: you started something, stopped it with Ctrl-C, and used up-arrow to recall and rerun a previous command.
Six common mistakes
- Not knowing where you are. The root of most "it didn't work".
pwdandlsfirst. rmwithout looking. No Trash, no undo.lsthe target first, every time.- Spaces in paths without quotes.
cd My Documentslooks for "My". Usecd "My Documents"or Tab completion, which handles it. - Not using Tab. Typing full paths by hand is slow and typo-prone. Tab is how it's actually done.
- Pasting commands you don't understand. Especially anything with
rm -rf,sudo, or a pipe tosh. Read every character first. - Fighting a stuck command instead of Ctrl-C. When in doubt, Ctrl-C and start over.
Exercise (40 min, verifiable output)
Do a real organising job — your Downloads folder is perfect, it's always a mess.
cdinto Downloads.pwdandls -lto survey it.mkdir -p sorted/images sorted/docs sorted/other— build a structure.- Use wildcards to move files by type:
mv *.jpg sorted/images/,mv *.pdf sorted/docs/, and so on. lseach destination to confirm the moves landed.- Use
grep -rto find every file under a folder containing a word you choose. - Count something with a pipe:
ls sorted/images | wc -l— how many images did you move? - Create a
README.txtwithtouch, and confirm withls. - Practise the safe delete: make a throwaway file,
lsit, thenrmit — building the look-before-you-delete habit on something that doesn't matter.
✅ Finish check: Downloads is organised into folders you made from the command line, you moved
files in bulk with wildcards, you searched with grep, and you counted results with a pipe.
Cheatsheet
GRAMMAR: command -flags arguments (verb · adverb · object)
WHERE AM I
pwd ls ls -l (detail) ls -a (hidden) whoami
MOVE
cd folder cd .. cd ~ cd - ← Tab completes names!
. = here .. = up one
LOOK
cat (short) less (long: / search, q quit) head tail wc -l
CREATE / COPY / MOVE / DELETE
mkdir mkdir -p a/b/c touch file
cp cp -r (folders) mv (rename AND move)
rm rm -r (folders) ⚠ NO TRASH, NO UNDO — ls before you rm
THE POWER TOOLS
* wildcard: mv IMG_* 2026/ rm *.tmp cp *.jpg photos/
| pipe: ls | wc -l cat log | grep error
grep -r "text" . ← search every file below here
NOT GETTING STUCK
Ctrl-C stop ↑ recall Ctrl-L clear man cmd / cmd --help
DANGER
rm -rf sudo | sh — understand every character before runningSources
- The Linux Documentation Project — command reference
- Apple — Terminal User Guide; GNU — Bash Reference Manual
- Shotts, W. — The Linux Command Line, 2019
Next lesson: TC-04 — Python From Zero (L1) Related: TC-05 Your First Real Script · TC-06 Git and GitHub · TC-01 What a Computer Actually Does Path: Ship Your First Thing — 3/7