Read manual pages
Nobody remembers every option of every command. Experienced administrators look things up constantly, and the first place they look is the system itself. Every package installs manual pages, man pages for short, that describe its commands and files, written for exactly the version installed.
- Open a manual page, and pick the right section when a name means two things.
- Move around a page and search inside it.
- Read a SYNOPSIS line: what to type literally, what to replace, what is optional and what may repeat.
Open a manual page
man followed by a name opens its manual page:
[student@workstation ~]$ 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 speci‐
fied.
...The page opens in less, so the keys you learnt in chapter 2 work here:
| Key | Does |
|---|---|
| Space / b | Next / previous screen |
| d / u | Down / up half a screen |
| ↓ / ↑ | One line |
/text Enter | Search forward; n next match, N previous |
| g / G | Start / end of the page |
| q | Quit |
The parts of a page
Pages follow the same layout, though few use every heading:
| Heading | What you find there |
|---|---|
| NAME | The name and a one-line description |
| SYNOPSIS | How to call it: the command line's shape |
| DESCRIPTION | What it does, and usually the options |
| OPTIONS | The options, when not in DESCRIPTION |
| EXAMPLES | Worked examples: often the fastest way to the answer |
| FILES | Files it reads or writes, such as configuration files |
| SEE ALSO | Related pages, with their section numbers |
Sections: one name, several pages
The manual is divided into numbered sections. The ones an administrator uses most are 1, 5 and 8:
| Section | Holds | Example |
|---|---|---|
| 1 | Commands any user runs | ls(1), passwd(1) |
| 2 | System calls (for programmers) | open(2) |
| 3 | Library functions (for programmers) | printf(3) |
| 4 | Special files, mostly devices | null(4) |
| 5 | File formats and configuration files | passwd(5), fstab(5) |
| 7 | Overviews, conventions, standards | regex(7), hier(7) |
| 8 | Administration commands, usually for root | useradd(8), mount(8) |
That is why pages are written as passwd(5): the name plus the section. passwd(1) is the command that changes passwords; passwd(5) describes the /etc/passwd file. man passwd opens the first match, section 1. Put the section number first to choose:
[student@workstation ~]$ man 5 passwdpasswd(5) File Formats Manual passwd(5)
NAME
passwd - password file
DESCRIPTION
The /etc/passwd file is a text file that describes user login accounts
...
Each line of the file describes a single user, and contains seven
colon-separated fields:
name:password:UID:GID:GECOS:directory:shellwhatis lists every page with a name, one line each, so you can see which sections exist:
[student@workstation ~]$ whatis passwd
passwd (5) - password file
passwd (1ossl) - OpenSSL application commands
passwd (1) - update user's authentication tokens1ossl is a sub-section that OpenSSL uses for its own commands.
Read a SYNOPSIS line
The SYNOPSIS uses a small set of conventions to say what you may type. Select each part of these two real examples:
Reading a SYNOPSIS line: Select a convention below to highlight where it appears in the two command lines.
| Notation | Means |
|---|---|
| bold or plain word | Type it exactly as shown |
| underlined or CAPITALS | Replace with your own value: a file name, a user name |
[ ] | Optional |
... | May be repeated |
{a|b} or a|b | Choose exactly one |
Some commands have several SYNOPSIS lines: each is a different way to call them. cp can copy one file to a new name, or several files into a directory:
SYNOPSIS
cp [OPTION]... [-T] SOURCE DEST
cp [OPTION]... SOURCE... DIRECTORY
cp [OPTION]... -t DIRECTORY SOURCE...Check your understanding
- Which command shows the manual page that describes the /etc/passwd file?
- Which manual section holds administration commands such as useradd and mount?
- You are reading a man page. How do you find the next place the word recursive appears?
- A SYNOPSIS reads: useradd [options] LOGIN. Which command fits it?
- What does the ... after SOURCE in cp [OPTION]... SOURCE... DIRECTORY mean?
- Which heading of a man page usually gets you to a working command fastest?