This guide shows how to navigate man pages using man.
The man program
Everyone at some point in their Linux life has used it. "It" is the
man command. However, while the man program itself appears to be rather simplistic in its construct, it has a few extra abilities than just simply scrolling through the page. This document hopes to help shed some light on these capabilities.
Man pages are mainly stored in the /usr/share/man directory. However, as long as a man page is located in the
MANPATH environment variable, man will be able to pick it up. Gentoo will generally store
MANPATH variables in /etc/env.d. Within these directories are some folders with the structure manX where X is the section number. For example, a standard man layout might look like so:
The actual section numbering appears fairly standard. However, notice that there is a mann and some man#p folders. The following table lists the above man page directories and what is contained within them:
|man0p|| The |
|man1||This section is for standard commands. Most programs will put their man pages here, so this section tends to be the largest.|
|man1p||This section describes the POSIX versions of the commands described in 1p. Since it only describes basic commands, it is much smaller than man1.|
|man2||This section describes Linux kernel system calls.|
|man3||This section describes standard C library functions.|
|man4|| This section describes special devices. These devices are generally kernel oriented, but |
|man5|| This section describes both the makeup of certain files and what files a program uses. Those of you reading this document may be familiar with references to |
|man6||This section introduces games and other special toys.|
|man7||This section describes standards and other miscellaneous items. These standards can include things such as charsets, SQL statements, ISO standards and regular expressions.|
|man8||This section describes administrative commands (those usually run by the root user).|
|man9||This section is somewhat sparse, but is meant to contain documentation for various parts of the kernel.|
|mann|| This section is mainly used by |
While this is not an extensive and detailed list, it does cover the man pages that most people will be interested in. However, sometimes you can find out what a section does as easily as looking at this table. The next chapter will look at using man to traverse this layout.
Working with the man layout
Browsing the man layout
Now that we understand the man layout, we can begin to look it over for commands. Sometimes we may need to narrow down what man page we want. The first way would be addressing by section. To found out a description of a section, once can use
man section intro like so:
Unfortunately, this doesn't always work! However, luckily for us there is another way to search for commands that may return multiple results (such as a library call and system command having the same name). To do so, we use the
-K parameter to man like so:
Sometimes the output may be a lot larger. In this case it might be better to specify more specific keywords. Now that we know where to find the man page, the next section will look at viewing the man page.
Viewing man pages
Viewing man pages can be done in 2 ways, first is with
man [man page name] . The second way is
man [section] [man page name]. Let's take
bc for example. I can view either the first man page that comes up on
bc (which would be section 1, because it is the lowest section containing a man page on
However, what if I want the POSIX version? Then I can use the second form:
And the man page is displayed. Now that we have the man page up, it's time to work with it. The next section will look at navigation and searching.
Navigating a man page is fairly simple. To move up and down line by line, use the Up and Down arrow keys. To move up page by page, you can use the Page up and Page down keys. Do however note that these navigation instructions assume the environmental
PAGER variable is set to use the default pager,
less. Less also has a few other commands for navigation, but the arrow keys usually suffice:
Searching, however, is more interesting. The two most basic searches are
?pattern. The first version searches forwards, and the second searches backwards.
pattern is a regular expression pattern that is described in
man 7 regex. Let's take for example searching for the
-D option to
emerge. First, bring up the emerge man page:
Then, at the screen, press the / key to bring up the entry prompt to search forwards and enter in our search pattern:
This will search the man page, and bring the searched item into focus:
If you hit a search result by accident and want to continue searching for the same results, simply press the / key again, and press Enter (i.e. don't put a pattern it). This will cause the search to default to the last pattern used. Now with some man pages, options are listed, then explained later on. Take the
man 5 portage man page. It lists the files used, then explains their usage. Searching forward a few times would return the results, but there's an easier way to handle this, with the second search form, backwards searching. Let's use this to find the description on package.unmask. First, bring up
man 5 portage:
Now press Shift + g. This will bring you to the end of the page:
Now we'll go ahead and enter the pattern to search for with the
?pattern backwards search option. First press the ? key to bring up the prompt, and then enter in
package.unmask, our query:
Then hit Enter to bring up the result:
And the search is complete! Note that just as with
? search with no pattern will use the last pattern to search.
This concludes the man guide. This will hopefully shed some light on navigating man pages, and maybe even give a few new tips to the more experienced users. For those who prefer alternate means of navigating man pages, the following are also available:
- app-text/man2html - a program for converting man pages to html
- app-text/tkman - a tk based man page browser
KDE web browser
Konqueror can browse man pages using the
man: syntax in the address bar.
We would like to thank the following authors and editors for their contributions to this guide:
- Chris White