The Man to Know
Man pages provide essential information but may seem cryptic if you're not familiar with their structure. We explain how they're organized so you can get the most out of them.
Man pages provide essential information but may seem cryptic if you're not familiar with their structure. We explain how they're organized so you can get the most out of them.
Few features are more closely associated with Unix-like systems than man pages [1]. First used in 1971 [2], man pages quickly became the standard form for online help. Even the GNU Project's preference for help formatted in Texinfo has done little to affect man's popularity, because, more often than not, man pages are available alongside Texinfo files.
Many users have come to take man pages for granted, using only the basic man
command and never considering how they are created or structured. However, even if you never write a man page yourself, knowing how they are organized externally and internally, as well as their conventions, can help you both find and read them more efficiently.
Most man pages are organized in sections or chapters (Table 1). To avoid confusion between files of the same name in different sections, man files take the format NAME.SECTION.bz
(or .gz
). Topics are usually referred to with the file name, followed by the section in parentheses (e.g., mount(8)
).
Table 1
Man Sections
Section Number | Subject |
---|---|
1 |
User commands |
2 |
System calls |
3 |
Library functions |
4 |
Devices |
5 |
Files in /dev, configuration files, and drivers |
6 |
Games and screensavers |
7 |
Miscellaneous |
8 |
System administration commands |
9 |
Kernel routines and daemons |
Sometimes, you also see an "l" section for local files generated by the local system administrators. In the past, some topics such as Tcl and the X Window System have also created their own sub-sections with their own naming conventions. However, these are non-standard practices that few modern Linux systems use.
When you enter the man
command, the program displays a page that might be appropriate. Unfortunately, it generally settles on the first one it encounters, a habit that means you might miss useful information unless a page with the same file name is mentioned at the end of a page. You could always add section numbers to the command systematically in the hope of finding more pages, but a better solution is to install whichman
, a command that lists identical file names in different sections (Figure 1). By default, whichman
also lists near equivalents, so that searching for parted
will also returns partx
, paste
, and parec
, but if you run it with the -e
option, it will return only identical names.
Most man pages are stored in /usr/share/man
or /usr/man
. However, some applications may have their own directories for man pages. Assuming you know about these additional directories, you can create a MANPATH
environment variable to include them.
Over the years, man pages have evolved a standard set of section headings (Table 2). These generally appear on a line by themselves, in uppercase letters.
Table 2
Man Page Structure
NAME |
SYNOPSIS |
CONFIGURATION |
DESCRIPTION |
OPTIONS |
EXIT STATUS |
RETURN VALUE |
ERRORS |
ENVIRONMENT |
FILES |
VERSIONS |
CONFORMING TO |
NOTES |
BUGS |
EXAMPLES |
AUTHORS |
SEE ALSO |
You do not have to include all section headings to compile a man page, and some make sense only for certain subjects, but if you depart from them too far, then any page that you write may not contain the information that readers come to expect. Others are a matter of choice, such as the AUTHORS, which purists consider irrelevant and others a means of getting their rightful credit.
The audience may also help to decide the sections to include. For example, DESCRIPTION, NOTES, and EXAMPLES are more likely to be used if the page is intended primarily for general users. By contrast, sections such as EXIT, STATUS, RETURN VALUE, and ERRORS are more likely to be used for system calls and library functions used most often by developers or system administrators.
However, most man pages include:
Additionally, commands (section 1 and 8) should always include a complete set of OPTIONS. The options are generally listed in alphabetical order, ignoring case, so that -l
is followed directly by -L
. Sometimes, for complicated commands with more than one function, the options may be divided into subcategories.
For each option, the Unix-style option of a hyphen and a single letter comes first, followed by an indentation and the GNU-style option of two hyphens followed by one or more words joined by hyphens (Figure 4). On a new indented line, the description of the option is given concisely, but in full detail.
Which other headings you include depends on what is necessary, but remember that man pages aim to be comprehensive, so too much information is preferable to too little.
Pages: 4
Price $15.99
(incl. VAT)