MARJ
SIGN IN
VIL1checked 2d ago

The Terminal: Your First 20 Commands and Why It Still Matters

Real work done in a shell: files organised, renamed in bulk, and searched — all from the command line

⚠️ 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 to

That'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

Step 01

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.


Step 02

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, date

Two 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 Doc and press Tab — it finishes Documents/. 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.


Step 03

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 lines

less 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.


Step 04

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 it

Three things worth internalising:

  • mv is both rename and move. Renaming is just moving to a new name in the same folder. One command, two uses.
  • touch + mkdir are how you scaffold a project structure in seconds instead of clicking through New Folder menus.

⚠️ rm does 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:

  1. ls the thing before you rm it. Confirm you're deleting what you think.
  2. Never, ever run rm -rf on 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 because rm obeys instantly and completely. When a command online contains rm -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.


Step 05

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 detail

Each 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 matches

grep -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.


Step 06

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 command when you forget the flags. Every command documents itself. The -l in ls -l? man ls tells 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

  1. Not knowing where you are. The root of most "it didn't work". pwd and ls first.
  2. rm without looking. No Trash, no undo. ls the target first, every time.
  3. Spaces in paths without quotes. cd My Documents looks for "My". Use cd "My Documents" or Tab completion, which handles it.
  4. Not using Tab. Typing full paths by hand is slow and typo-prone. Tab is how it's actually done.
  5. Pasting commands you don't understand. Especially anything with rm -rf, sudo, or a pipe to sh. Read every character first.
  6. 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.

  1. cd into Downloads. pwd and ls -l to survey it.
  2. mkdir -p sorted/images sorted/docs sorted/other — build a structure.
  3. Use wildcards to move files by type: mv *.jpg sorted/images/, mv *.pdf sorted/docs/, and so on.
  4. ls each destination to confirm the moves landed.
  5. Use grep -r to find every file under a folder containing a word you choose.
  6. Count something with a pipe: ls sorted/images | wc -l — how many images did you move?
  7. Create a README.txt with touch, and confirm with ls.
  8. Practise the safe delete: make a throwaway file, ls it, then rm it — 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 running

Sources

  1. The Linux Documentation Project — command reference
  2. Apple — Terminal User Guide; GNU — Bash Reference Manual
  3. 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

Mark it when you've got the output in hand.

← All Technical Foundations lessons