The Linux terminal, one command per page
The twenty-six commands that cover everything you do every day.
Read the terminal. Lose the fear.
The Linux terminal, one command per page
The twenty-six commands that cover everything you do every day.
Set in Space Grotesk, Inter and JetBrains Mono (SIL Open Font License).
Command behaviour verified against the man-pages project: man7.org/linux/man-pages, and the GNU coreutils manual: gnu.org/software/coreutils/manual
Your purchase is for personal use only. You do not have redistribution rights: please do not share, resell, or republish this book or its pages.
© 2026 Steve Hodgkiss. All rights reserved. Personal use only; no redistribution rights.
Edition 1.0 · stevehodgkiss.net
Contents
Finding your way
Orientation first. The terminal can't guess: these five commands ask it where you are and what you're looking at.
- 01ls
- 02cd
- 03man
ls lists directory contents. Plain ls shows names; ls -l shows the long form with permissions, owner, size and date; ls -a includes dotfiles like .bashrc.
ls
The everyday form is ls -lah: l long, a includes dotfiles like .bashrc that plain ls skips, h prints sizes as 1.2K, not byte counts. Deleting from a plain listing means the dotfiles you can't see are still there. Look with the long form before touching anything.
Look at the folder before you touch the folder.
ls -lah
cd changes the working directory. With no argument it goes to HOME, cd .. goes up one level, and cd - returns to the previous directory.
cd
Four forms cover everything: cd somewhere, cd .. up, cd home, cd - back. ~ always means home, so cd ~/projects works from anywhere. cd doesn't carry you back by itself; if you lose track, pwd. Between pwd and cd, the tree stops being a maze.
One dot is here, two dots is up.
cd ~/projects
man shows the manual page for a command: NAME, SYNOPSIS and DESCRIPTION, with every flag documented. It opens in less, so arrows scroll, / searches and q quits.
man
Read in order: NAME, the job in one line; SYNOPSIS, the argument shapes, brackets optional; DESCRIPTION, every flag. The number in LS(1) is the section: 1 commands, 5 file formats, 8 admin, which is why man 5 passwd differs from man 1 passwd. Every answer is one q away.
The manual ships with the machine.
man ls
Reading and shaping text
Config files, logs, command output. It's all text, and these commands read it, filter it, and pass it to each other.
- 01cat
- 02grep
- 03| pipe
cat concatenates files to standard output. For short files it is the quickest look; for long ones the output outruns the screen and less is the tool.
cat
The name means concatenate: three files in, all three printed in order, which is exactly what pipelines want. cat a 40,000-line log and it's gone before your eyes reach the top; that's less territory. cat -A shows tabs and line endings when a file looks garbled. One screen fits, cat is fastest.
Short file, cat it. Long file, less it.
cat notes.txt
grep prints the lines that match a pattern. -i ignores case, -r searches a directory recursively, -n prefixes file and line numbers, -v inverts the match, -c counts lines.
grep
-r walks directories, -n numbers lines so your editor can jump; then the trimmers: -i case, -v invert, -c count. Unquoted multi-word patterns arrive as two arguments and the error explains nothing, so quote. It reads stdin too, which is why pipes and grep are inseparable. Any text you can see, you can filter.
If it's text, grep can find the line.
grep -rn "TODO" src/
The pipe feeds one command's standard output into the next command's standard input, so small single-purpose tools compose into one job.
| pipe
Read it like a sentence: history prints, uniq counts, sort orders by count, head keeps the top. Each stage holds its input whole, so size isn't your problem. A chain is only as right as its first filter; when a result looks off, run the first two stages alone. This one character is why the terminal is a workshop, not a menu.
Small tools, wired together.
history | sort | uniq -c | sort -rn | head
rm deletes files outright: no trash, no undo, no confirmation by default. -r removes directories and everything inside, -i prompts per file. Quote paths and check variables before pressing Enter.
rm
Let's say you're tidying up and type rm -rf $TMPDIR/ from a tutorial. If the variable is set, fine. If it's empty, the path vanishes from the command and it runs in the folder you're standing in. There is no trash, no undo, and no confirmation by default.
The safe shape is rm with names you can see; folders need -r, and -i asks per file. Before any rm with a variable in it, run the identical line with ls instead: it shows exactly what rm would touch. rm is for when you're certain. ls is how you get certain.
No trash can. ls the path first.
rm old-notes.txt
chmod changes permission bits. Symbolic modes like u+x and go-r name who and what; numeric modes use three octal digits, each read=4 write=2 execute=1, so 7 is rwx and 5 is r-x. On a symlink, chmod follows the link.
chmod
Let's say you wrote deploy.sh, typed it perfectly, and the shell answers "Permission denied". chmod rewrites a file's permission bits, and the ones you want are chmod 755 deploy.sh.
Three groups of three bits: owner, group, everyone, each digit adding read 4, write 2, execute 1. The word form works too: chmod u+x script. 777 hands the file to the world and is never the fix; stubborn "Permission denied" is usually ownership, next page. 600 for secrets like keys, 755 for things that run.
Three digits. Each one is 4, 2, 1 added up.
chmod 755 deploy.sh