← All 45 books The Linux terminal, one command per page Get the full edition · £10
One command per page

The Linux terminal, one command per page

The twenty-six commands that cover everything you do every day.


Steve Hodgkiss 8 commands

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

Contents


Part 1 · Finding your way4
ls5
cd6
man7
Part 2 · Reading and shaping text8
cat9
grep10
| pipe11
Part 3 · Changing things
rm12
Part 4 · Permissions and users
chmod13
Part 1 of 4
Where am I, what is here
1

Finding your way

Orientation first. The terminal can't guess: these five commands ask it where you are and what you're looking at.


In this part
  1. 01ls
  2. 02cd
  3. 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.

Linux · No. 01
Finding your way

ls

What is actually in this folder

ls (plain)app.pynotes.txt.bashrchidden, not shown-lahls -lah-rw-r--r-- 1 steve steve 1.2K notes.txtdrwxr-xr-x 2 steve steve 4.0K .config-rwxr-xr-x 1 steve steve 860 deploy.shmode · owner · size · name (l=long, a=all, h=human sizes)Plain names for a quick look. The long form for knowing what you're touching.

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.

TRY IT NOW

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.

Linux · No. 02
Finding your way

cd

Move to another directory

/homeetcprojectstmpcd projectscd .. upcd - backcd homeOne dot is here. Two dots is up. cd - retrace

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.

TRY IT NOW

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.

Linux · No. 03
Finding your way

man

The manual that is already installed

LS(1)NAME ls - list directory contentsSYNOPSIS ls [OPTION]... [FILE]...DESCRIPTION what -a reallydoes, option by optionarrows scroll · / searchesn next match · q quitsman -k copy search by wordEvery command you'll meet documents itself.

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.

TRY IT NOW

man ls

Part 2 of 4
Everything is lines
2

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.


In this part
  1. 01cat
  2. 02grep
  3. 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.

Linux · No. 04
Reading and shaping text

cat

Pour a file onto the screen

notes.txtline oneline twoline threestdoutline oneline twoline threea 40,000-line logscrolls past in ablink. Use less.cat pours the whole file out at once. Short files only.

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.

TRY IT NOW

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.

Linux · No. 05
Reading and shaping text

grep

Find the line you meant

index.htmlapp.pystyles.cssgrep -rn"TODO" src/src/app.py:12: # TODO retrysrc/app.py:47: # TODO rate limit-n numbers the lines, -r walks src/-i ignore case · -v invert · -c just countfile:line:text. That is the whole output format.

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

TRY IT NOW

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.

Linux · No. 06
Reading and shaping text

| pipe

One command's output, the next one's input

grep nginxkeeps the lines|sort -rorders them|head -n 3keeps the topyour screenhistory | sort | uniq -c | sort -rn | headEach command does one job. The pipe is the grammar.

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.

TRY IT NOW

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.

Linux · No. 07
Changing things

rm

Delete, without a safety net

rm old-notes.txtone named file, gone.-i asks before each removalrm -rf $TMPDIR/with TMPDIR empty this runs in thecurrent directory. There is no undo.the exit ramp: mv suspect/ trash/ then empty trash/ when sure

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.

TRY IT NOW

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.

Linux · No. 08
Permissions and users

chmod

Three digits, three groups, one file

-rwx r-x r-xowner group everyonethreedigits74+2+1 rwx54+1 r-x54+1 r-xr=4 w=2 x=1 → chmod 755 deploy.sh600 private file (key) · 644 normal file · 755 script or folder

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.

TRY IT NOW

chmod 755 deploy.sh

Index

Index


cat9
cd6
chmod13
grep10
ls5
man7
rm12
| pipe11