Command Help — Asking the System Itself
Nobody remembers every option of every command. Experienced Linux users aren't people who know everything. They're people who know how to look things up in seconds, without leaving the terminal. The documentation is already installed, and you just need to know how to reach it.
The rule
Ask the command first: --help for a glance, man for the full story.
--help prints a short summary straight to the terminal. Most GNU commands support it:
$ sort --help
Usage: sort [OPTION]... [FILE]...
-n, --numeric-sort compare according to string numerical value
-r, --reverse reverse the result of comparisons
...man opens the full manual page:
$ man sortThe page opens in a pager (usually less), and a few keys are all you need:
| Key | Does |
|---|---|
Space / b |
page down / back |
/word |
search for "word"; n goes to the next match |
q |
quit |
Manual pages are split into numbered sections, and the section number appears in brackets, as in passwd(1):
| Section | Holds |
|---|---|
| 1 | user commands |
| 5 | file formats, such as config files |
| 8 | administration commands |
So man passwd shows the passwd command, and man 5 passwd shows the format of the /etc/passwd file.
Don't know the command's name? Search the short descriptions of every manual page:
$ man -k compress # same as: apropos compress
gzip (1) - compress or expand files
...Shell builtins such as cd and export are part of the shell itself, so they may not have their own man page. In Bash, help cd explains them. type cd tells you whether something is a builtin.