Linux Command Reference ยท System Information
Linux man command
Reference for the Linux man command: open manual pages, pick the right section, search with -k and /, read the layout of a page and find options quickly.
man displays the manual page of a command, system call, library function or file format. Manual pages are the reference documentation that ships with the software itself, so they match the installed version and work offline.
Pages are grouped into numbered sections, and man shows them through a pager (normally less). Many minimal systems and containers do not install man or the pages at all, so the examples here that run on this site demonstrate the ideas around it; the man invocations themselves are read-only.
man [SECTION] NAME
man -k KEYWORD
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
man [-k | -f] [-s SECTION] [-a] [-w] [-P PAGER] [SECTION] PAGE...
| Usage | Description |
|---|---|
man ls |
Open the first page named ls found. |
man 5 passwd |
Page passwd from section 5 (the file format, not the passwd command in section 1). |
man -k word |
Search names and descriptions (same as apropos). |
man -f name |
Short description of a page (same as whatis). |
man -a name |
Show every matching page one after another. |
man -w name |
Print the file path of the page instead of showing it. |
man -P cat name |
Use a different pager; cat dumps the whole page. |
man ./file.1 |
Render a local manual file. |
A page usually has these headings: NAME, SYNOPSIS (square brackets mean optional, ... means repeatable, | means a choice), DESCRIPTION, OPTIONS, EXIT STATUS, ENVIRONMENT, FILES, EXAMPLES, SEE ALSO, BUGS.
Keys inside the pager (less): Space/b page down/up, /text search forward, n and N next and previous match, g and G top and bottom, q quit, h help.
Returns: 0 on success; 16 when no manual entry exists (No manual entry for xyz).
Usage notes
- Pick the right section.
man 1 printfvsman 3 printf; the pages cross-reference each other asprintf(3).man 7pages (man 7 signal,man 7 regex,man 7 glob) are excellent overviews. - Find the option fast: inside the page type
/^ *-r(a regular expression) to jump to an option's description. - Shell builtins have no own page.
man cdshows a short "BASH BUILTIN COMMANDS" page; usehelp cdorman bash. Seeinfoandhelp. - Plain text for files or pipes:
man ls | col -b > ls.txtstrips overstrike formatting; settingMANWIDTH=80fixes the line width. - Search the manuals:
man -k keywordneeds the manual database (mandb) to be built; right after installing it may say "nothing appropriate". - Not installed?
apt install man-dbon Debian/Ubuntu ordnf install man-db. Docker images remove man pages on purpose to save space. - Colors in the pager: set
LESS_TERMCAP_*variables or usebatman/MANPAGERfor syntax highlighting. - Online vs local: a web copy of a manual page may be for a different version than what you run. Trust the local page for your system.
Related
apropos,infoandhelp,less,type- Lessons: Getting help, Viewing text