Getting Help Yourself: man, --help & apropos
- Read a man page: the standard sections and how to navigate with less
- Decode SYNOPSIS notation — [optional], required, ... repetition
- Pick the right tool: man vs --help vs whatis for the question you actually have
- Find a command whose name you don't know with apropos (man -k)
- Use man sections (1 commands, 5 file formats, 8 admin): man 5 passwd vs man passwd
The skill that outlasts every command
See why the built-in docs beat a web search — then open one.
Here's a secret that takes the pressure off: nobody memorises Linux. The engineers you watch move fast aren't recalling ten thousand flags from memory — they're looking things up, just very quickly, because they know where the answers live. This lesson teaches you that skill, and it's the one that makes every other lesson optional: once you can read the manual, you can figure out any command for the rest of your career.
And the manual really is right there. Almost every command ships with a manual page — a "man page" — that documents exactly the version installed on this machine.
Why reach for the man page before a web search? Three reasons that matter especially on real servers:
- It's offline. It works on a locked-down box with no internet — where a lot of real work happens.
- It's authoritative. No out-of-date blog post, no answer for a different distro — it's the actual documentation for the actual software.
- *It matches your version.* The flag it describes exists, spelled exactly that way, on the machine in front of you. A web result can't promise that.
So the habit to build is simple: when you don't know, check the manual first.
Example — not runnable on your lab box
man lsLS(1) User Commands LS(1) NAME ls - list directory contents SYNOPSIS ls [OPTION]... [FILE]... DESCRIPTION List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified. ...The man page opens in less— the same pager you already know from reading files. And the layout is ALWAYS the same, which is what makes man pages fast once you're used to them: NAME (a one-line summary), SYNOPSIS (how to invoke it), DESCRIPTION (every option explained), then usually EXAMPLES and SEE ALSO near the bottom. When you open an unfamiliar page, jump to EXAMPLES first — it's often all you need.Check yourself
Inside a man page, which key starts a search?
Decoding the SYNOPSIS
Read the compact notation that tells you exactly how a command may be invoked.
The SYNOPSIS line looks cryptic but it's a tiny grammar, and three rules decode all of it:
- `[brackets]` = optional.
ls [OPTION]... [FILE]...means options and files may both be left off — plainlsis legal. - bare words (or `<angle brackets>`) = required.
mv SOURCE DEST— you must supply both, in that order. - `...` = repeatable.
[FILE]...means you may pass many files.
Put together,
cp [OPTION]... SOURCE... DIRECTORYreads as: any number of options, one or more sources, exactly one destination directory. Once this clicks you can learn a command's shape in about five seconds — which is most of what you need to start using it.One more piece of the puzzle: the number in that
LS(1)header is the manual section. The manual is split by kind of thing, and the same name can appear in more than one:- 1 — user commands (
man ls) - 5 — file formats (
man 5 passwd= the format of/etc/passwd, not the command) - 8 — system-admin commands (
man 8 useradd)
When a name lives in several sections,
manshows the lowest by default. Soman passwdgives the password-changing command (section 1), whileman 5 passwdgives the file format. If a page seems to be describing the wrong thing, glance at its section number first — that's usually the mix-up.Check yourself
In a SYNOPSIS, what do square brackets around an argument mean?
- `[brackets]` = optional.
--help, whatis, and finding commands with apropos
Match the help tool to the question you actually have.
manis the full manual, but sometimes it's more than you need — or you don't even know the command's name yet. Three lighter tools each answer a different question:- `cmd --help` — "just remind me of the flags." A fast, terse summary printed straight to the terminal (no pager). Perfect when you know the command and almost remember the option.
- `whatis cmd` — "what is this thing, in one line?" Prints only the NAME line from the manual.
- `apropos keyword` (identical to
man -k keyword) — "I don't know what it's called." Searches every man page's one-line description for your keyword and lists the hits. This is the reverse lookup: describe the job, get the tool.
whatis lsls (1) - list directory contents
The one-line answer to "what is this?" — just the NAME line, section number included. Great for a quick sanity check that a command is what you think it is before you run it, without opening the whole manual. apropos "list directory"dir (1) - list directory contents ls (1) - list directory contents vdir (1) - list directory contents
Here you described the job — 'list directory' — and aproposfound every command whose man-page summary matches,lsamong them. This is the move for "I know what I want to do but not which command does it": describe it, and let apropos hand you the candidates (with section numbers, so you know a(8)result is admin-flavoured).df --help | head -10Usage: df [OPTION]... [FILE]... Show information about the file system on which each FILE resides, or all file systems by default. Mandatory arguments to long options are mandatory for short options too. -a, --all include pseudo, duplicate, inaccessible file systems -B, --block-size=SIZE scale sizes by SIZE before printing them; e.g., '-BM' prints sizes in units of 1,048,576 bytes; see SIZE format below -h, --human-readable print sizes in powers of 1024 (e.g., 1023M)- --help
- print a terse usage + flag summary straight to the terminal
--helpis the quick-reference card: a usage line plus the flag list, printed inline with no pager to quit out of. Piping toheadkeeps just the top of it. Notice it hands you-h(human-readable) immediately — often--helpis faster thanmanwhen you just need to jog your memory on one flag.Check yourself
You need a command but don't know its name — which tool searches all man-page descriptions by keyword?
Worked example: discover a flag you've never used
Walk the full loop — question → man search → flag → verified result.
Let's run the whole skill on a real question. The task: list a directory oldest file first. You know
ls; you don't know the flag. Watch the loop:1.
man ls, then/sort— pressnthrough the matches until you land on-t(sort by time, newest first).2. Newest-first is backwards from what you want. Search
/reverse→-r(reverse the order while sorting).3. Combine them:
ls -tr= time-sorted, reversed = oldest first. Then verify against a directory whose order you can predict.That four-beat loop — ask → search → combine → verify — is the skill. Nothing about it is specific to
ls; it's how you'll meet every unfamiliar command from here on.ls -1tr /var/log/*.log/var/log/bootstrap.log /var/log/dpkg.log /var/log/alternatives.log
- -1
- one entry per line
- -t
- sort by modification time, newest first
- -r
- reverse the sort order
-tsorts by modification time (newest first); adding-rreverses it, so the OLDEST file leads and the freshest is last — exactly what you'd want when hunting the first log entry of an incident.-1forces one name per line, so the order is unmistakable. Three flags, found in thirty seconds ofman ls, composed into an answer you can trust.Check yourself
Which ls flag combination lists files oldest-first?
Now do it — answer your own question
Read it, then run it. Practise the reverse-lookup and quick-reference tools live.
You have a real shell to the right. Run the loop yourself — the point isn't these specific answers, it's building the reflex of reaching for the docs first. Do these and notice how rarely you actually need to leave the terminal to find something out.
whatis grep && grep --help | head -4First the one-line 'what is this?' for grep, then its quick flag reference. Two tools, two questions, one line — this is the fastest way to size up a command you half-remember.apropos password | head -5Reverse lookup: you don't remember the command to change a password, so you describe it. Scan the results and their section numbers — a (1)is the user command, a(5)would be a file format, a(8)an admin tool. Describe the job, read the list, pick the right section.
- The documentation is built in: man pages are offline, authoritative, and matched to your installed version — the skill of reading them outlasts any single command.
- Man pages open in less: / to search, n/N to hop matches, q to quit. SYNOPSIS grammar: [optional], required, ... repeatable. Jump to EXAMPLES first on an unfamiliar page.
- Three tools, three questions: man (the full manual), cmd --help (quick flag reference), whatis (one-line summary) — and apropos / man -k when you don't know the command's name.
- Sections matter: man passwd (1, the command) vs man 5 passwd (the file format); 8 is admin commands. When a name repeats, man shows the lowest section by default.
- The working loop: ask → search the man page → combine flags → verify the result. Make reaching for the docs your first reflex.
| You want… | Reach for |
|---|---|
| The full manual for a command | man cmd |
| A quick flag reminder | cmd --help |
| A one-line 'what is this?' | whatis cmd |
| A command whose name you don't know | apropos keyword |
| The file-format docs, not the command | man 5 name |
| To search inside a man page | /word · n · q |
