Unix provides online help for commands, system calls and other Unix related information through the manual pages, more commonly known as man pages. There are two ways to view the man pages:

There are also other ways to get quick references to commands:

The man Command

The man command is used to display the manual pages. Its format is:

% man name

where name is the command we want information about. For example, to view the man page for the mkdir command, we would type:

% man mkdir

and then the Unix man page for mkdir would be displayed in the xterm window as follows:

This is the first screenful of the mkdir man page. To view the next line, we type [return]; to view the next screenful, we type [space].

Description of Manual Pages

Man pages are written as a reference manual for experienced Unix users and programmers. They contain more information than a typical user will need, so they might seem confusing at first. Man pages are organized in several sections to categorize information:

Organization of Manual Pages

Manual pages are divided into several sections. The number of sections and their content vary depending on the version of Unix. The following table shows a typical organization of the man files in a Unix system:

Section Number Contents
1 User commands and basic utilities.
2 System calls and error numbers.
3 Subroutines and programming libraries.
4 Special files. Hardware peripherals and device drivers.
5 File formats used or read by various programs.
6 Games and demos.
7 Miscellaneous -- macro packages, character set tables, etc.
8 System administration commands.

There might also be sections labeled l or n for locally installed man pages. Some command names have more than one manual page associated with them. For instance, the mkdir command is described in sections 1 and 2. To find out more about a command from a specific section, type:

% man section_number command
where section_number is a section number from the above table. For example, to view the mkdir man page in section 1 of the Unix man page, type:
% man 1 mkdir
In some systems, we need to specify a -s option for viewing a particular section of the man page. The form of the command then becomes:
% man -s section_number command

Searching by Keyword

Man pages can be frustrating to use since we must know the name of the command we are looking for before we can locate the associated man file. The man program can search for man pages that contain a specific keyword using the -k option.

Suppose that we want to change our password, but can not remember the command yppasswd. Doing a keyword search on password through the man pages may help us find the command. To locate all of the man pages whose title or summary description contains the keyword password we would type:

% man -k password

Unix will search the man pages and then display:

passwd       (5)  - password file
yppasswd     (1)  - change your password in the NIS database

If the summary is not enough to tell us which command is the one we want, we can view the man pages for both passwd and yppasswd.

Printing Man Pages

To print a manual page, we type:

% man command_name | print -Pprinter_name

Here the vertical bar, called a pipe |, is used to join the two commands together (we will learn more about combining commands later). Here, the output of the man command, a man page, is sent to the print command for printing.

More about man

For more information about the man command on a specific system, we can even type:

% man man

The xman Command

If we are running X Windows, then we can use the xman program to get help with Unix commands, system calls, and other Unix related information. To run xman, we simply type:

% xman

A window, similar to the following, will appear:

xman Window

Clicking on the "Manual Page" button brings up a window called "Manual Page". For detailed instructions on how to use xman, it suffices to click on the "Help" button.

Using xman

If, starting from the "Manual Page" window, we use the "Sections" menu to select the "User Commands" section, then a list of commands will be displayed in the "Manual Page" window:

We can then find the command we want in the alphabetical list of manual entries, and click on the command name to display the man page for that command in the "Manual Page" window.

Searching by Keyword

To search for the man page of a specific command, we choose "Search" from the "Options" menu. A window called "Search" will come up. Typing the name of the command to be searched for in the "Search" window, and clicking on "Manual Page" in the "Search" window, will lead us to the manual page for the command.

To search using a keyword, we follow the same steps but click on "Apropos" in the "Search" window for a list of commands associated with the keyword.

The whatis command

The whatis command displays a one-line summary of a command. The form of the whatis command is:

% whatis command

where command is the name of the command whose function we want to know.

For example, to get a quick reference for the mkdir command using whatis, we would type:

% whatis mkdir

and the output in xterm would be:

mkdir                (1)  - make directories
mkdir                (2)  - create a directory

The first column in the output is the name of the command. The number in parentheses tells us in which section of the Unix man pages the command is located. In this case, mkdir is located in both sections 1 and 2 (the first section describes the command, the second section describes system calls that can be used by a C or C++ program). The last column is the brief description of the command.

Reading man Pages in Emacs

The emacs editor has a command for viewing man pages in the buffer. This command is very useful when we are writing code in emacs and want to find out the function and usage of a particular command. This command has the form:

[Esc][x]man[Return]name[Return]

where name is the name of a command. This emacs command is entered at the echo area.

To view the ls man page, we would type:

[Esc][x]man[Return]ls[Return]

which would result in a horizontal screen-split in the buffer, and the ls man page appearing in the bottom buffer in a way similar to the figure below:

Emacs is a very useful editing tool. To learn more about it, go to the section on the Emacs text editor.