Academic Computing Services * Simon Fraser University

HOW TO

Use Unix online documentation (man pages)

© February 8, 1996 B-10



Unix systems have an online documentation feature called man pages. The man command displays information from the official Unix reference manuals (man is short for manual).

You can view the man page entry for a specific Unix command or program, or search all the man pages for keywords you specify.

Using man

The basic use of man is straightforward. Type man, followed by the command you're interested in. For example, to find out about the tail command, type

man tail

The man page entry for tail is shown below.

man page for the tail command
 TAIL(1)

 

NAME

 tail - deliver the last part of a file



SYNOPSIS

 tail [ +[number][lbc[f] ] ] [ file ]



DESCRIPTION

 tail copies the named file to the standard output beginning at a

 designated place.  If no file is named, the standard input is used.



 Copying begins at distance +number from the beginning, or -number from

 the end of the input (if number is null, the value 10 is assumed).

 Number is counted in units of lines, blocks, or characters, according to

 the appended option l, b, or c.  When no units are specified, counting is

 by lines.



 With the -f (``follow'') option, if the input file is not a pipe, the

 program will not terminate after the line of the input file has been

 copied, but will enter an endless loop, wherein it sleeps for a second

 and then attempts to read and copy further records from the input file.

 Thus it may be used to monitor the growth of a file that is being written

 by some other process.  For example, the command:



      tail -f fred



 will print the last ten lines of the file fred, followed by any lines

 that are appended to fred between the time tail is initiated and killed.

 As another example, the command:



      tail -15cf fred



 will print the last 15 characters of the file fred, followed by any lines

 that are appended to fred between the time tail is initiated and killed.



SEE ALSO

 dd(1M).



BUGS

 Tails relative to the end of the file are stored in a buffer, and thus

 are limited in length.  Various kinds of anomalous behavior may happen

 with character special files.



WARNING

 The tail command will only tail the last 256 Kbytes of a file regardless

 of its line count.

 

Page 1                       Release 3.3.2                       May 1990

If the man page entry is longer than can be displayed on the screen, press the spacebar to see the next screenful. If you don't want to look at the whole entry, type q to interrupt the display.

man page entries are displayed using the more command. See how-to B-7, Examine Unix Files and Redirect Output, for additional information about more, including how to search for words within a man page entry.

Understanding man

At first (and even second) glance, the online manual pages may seem intimidating. They are written for experienced Unix users and programmers, and contain complete information on all the options and associated files for a command.

Here is a brief description of the components of a typical man page:

The first line of a man entry shows the command or utility's name, followed by a number in parentheses. This number refers to the section of the manual where the entry is located (see the section Organization of man below).

Searching by keyword

The abundance (and often cryptic nature) of Unix commands sometimes makes it difficult to remember which command you want. You can ask Unix to search through the man pages looking for a particular keyword.

For example, suppose you want to set permissions for a file but can't remember the name of the command to do this. To search the man pages for the keyword permission, type

man -k permission

Unix performs the search and displays:
chmod (1) - change the permissions mode of a file or directory

uucheck (1M) - check the uucp directories and permissions file

writem (3G) - grants write permission to bitplanes

The command you were trying to remember is chmod. Other commands relating to permissions are also listed. (how-to B-6, Permit Unix Files and Directories, describes chmod.)

Finding out what a command does

Sometimes you can remember a command name but not exactly what it does. To display just the NAME section of a man entry, type whatis followed by the command you're interested in. For tail, type

whatis tail

tail (1) - deliver the last part of a file

Organization of man

The online manual is divided into several sections as follows:
1commands and basic utilities
2system services and error numbers
3subroutines and libraries
4file formats used or read by various programs
5miscellany - macro packages, character set tables, etc.
6games and demos
7special files - hardware peripherals and device drivers

To find out what a particular section contains (section 4 in this case), type

man 4 intro

Sometimes man entries for the same command are found in two different sections. For example, the command chmod has man page entries in section 1 and section 2. Using the basic form of the man command (man chmod) will display the entry in section 1 followed by the entry in section 2. To see the entry in only one section, type the section number before the name of the command. To see only the section 1 entry for chmod, type

man 1 chmod

Printing man pages

To print a man entry (for example, the one for chmod), type

man chmod | lpr

(The command lpr begins with a letter l, not a number 1.) The "|" (vertical bar) is the Unix pipe symbol, described in how-to B-7, Examine Unix Files and Redirect Output.

The -t option on the man command invokes the troff text processor to format man entries in a "typeset" style. However, man -t can only be used to format man entries for locally-added Unix programs like mpage and msgs, not for standard Unix commands like chmod and more.

To print the man entry for mpage, type

man -t mpage

The output will automatically be sent to the default printer queue; lpr is not needed in this case.

Capturing man pages in a text file

Man pages contain some unprintable characters, so typing

man chmod > chmod.man
will not produce a readable text file of the man entry for chmod. To capture the man entry for chmod in plain text in a file chmod.man (for example, to download and print on your home printer), type
man chmod | col -bx > chmod.man

More about man

For more on the man command, type (you guessed it! :-)

man man

* * * * * * * * * * * * * * *

This page written and maintained by Academic Computing Services, Simon Fraser University.
Please e-mail questions or comments to help@sfu.ca.