man: read the manual
Every Unix system carries its own documentation. man shows the manual page for a command, file format or system call, and man -k helps you find the right page when you do not know the name.
Examples
man ls # the manual for ls
man 5 crontab # section 5: the crontab file format (not the command)
man -k "disk usage" # search page names and descriptions (same as apropos)
whatis passwd # one-line description of every "passwd" page
man -f passwd # the same
man -w ssh # where the page file is
man -a passwd # show every matching page, one after another
Pages open in a pager, usually less: Space pages down, / searches, n finds the next match and q quits. A good trick is to search for an option directly: in man rsync, type /--delete.
Manual sections
| Section | Contains |
|---|---|
| 1 | User commands |
| 2 | System calls |
| 3 | Library functions |
| 4 | Device files |
| 5 | File formats and configuration files |
| 6 | Games |
| 7 | Overviews and conventions (e.g. man 7 regex) |
| 8 | System administration commands |
That is why you see names like crontab(5) in documentation. On older System V systems and Solaris up to 11.3, file formats are in section 4 and administration commands in 1M; Solaris 11.4 switched to the numbering above.
Reading a man page
Pages follow the same structure: NAME, SYNOPSIS, DESCRIPTION, OPTIONS, EXAMPLES, FILES, SEE ALSO. In the synopsis, square brackets mean optional, ... means repeatable, and a | b means one or the other. Many pages have an EXAMPLES section near the end: press G to jump to the end and scroll up.
When there is no man page
command --help # short help built into most GNU and modern tools
help cd # shell built-ins such as cd, read, export (bash)
info coreutils # GNU's longer manuals
sudo apt install man-db manpages # minimal and container images often lack pages (on Ubuntu run unminimize first)
sudo mandb # rebuild the search index if man -k finds nothing
Online
- man7.org: the Linux man pages, kept current.
- FreeBSD manual pages and OpenBSD manual pages, known for their quality.
- tldr pages: short, example-first summaries (
tldr tarwith a tldr client). - explainshell.com: paste a command line to see each part explained.
And of course the rest of the command reference on this site.