Writing and reading man pages

Lead Image © Dietmar Hoepfl, 123RF.com

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.

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.

Man Sections

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



User commands


System calls


Library functions




Files in /dev, configuration files, and drivers


Games and screensavers




System administration commands


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.

Figure 1: If you consult man pages regularly, installing whichman can help you find relevant pages.

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.

Man Page Section Headings

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


















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:

  • NAME: Includes at least the topic and its section in upper case. The date of the last revision and the function or system call from which a command derives may also be included – if only as Linux or GNU. Typically, tabs distribute the information against the left margin, middle, and right margin of the first line, even if information is repeated.
  • SYNOPSIS: The basic structure for the command, with all options displayed in square brackets and in the correct position (Figure 2). Because some options may be incompatible with each other, or some commands may be used for different purposes, the synopsis may include several lines. Variables such as the file name may be underlined.
Figure 2: The SYNOPSIS or basic command structure for the cp command, showing several variations.
  • DESCRIPTION: A brief explanation of the topic, including the files it interacts with, and its standard input and output. The description also describes typical ways that the topic may be used.
  • SEE ALSO (if relevant): Man pages and web pages for related topics, including pages with the same name in a different section, arranged in a comma-separated list (Figure 3).
Figure 3: The SEE ALSO section lists additional sources of information.

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.

Figure 4: A selection of options for the cp command.

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.

Buy this article as PDF

Express-Checkout as PDF

Pages: 4

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content