UH Navigation bar CS VNET NSM UH SEARCH

Computer Science Department Unix Primer

Man pages

When all else fails, read the manual

man is one of the most useful commands in Unix. This keeps experienced Unix gurus from having to learn all the command-line switches for each command under each version of Unix. For novices, a working knowledge of the man command can make the difference between frustration and enlightenment, for you can search through the man pages to find what cryptic Unix command will accomplish the task you are interested in.

The basic man syntax is

man [options] topic
e.g.
$ man man
Really, try 'man man'. That's the "reflexive" property of man. (A little joke for the math majors out there.)

The man pages are divided into sections for various commands. You can type

$ man -s [section] intro (solaris)
$ man [section] intro (linux)
to find out what each section contains.
SectionPurpose in Solaris Purpose in Linux
1User Commands
2System Calls (for programming)
3C Library Functions (for programming)
4File FormatsSpecial Files
5Headers, Environments, MacrosFile Formats
6Games and Demos
7Device and Network InterfacesConventions and Miscellany
8System Commands

Thus, if you are trying to get the man page for the system call, mkdir(2), but man defaults to giving you the page for the user command, mkdir(1), you can specify the section you want on the command line with the following syntax:

$ man -s 2 mkdir (solaris)
or
$ man 2 mkdir

One of the most useful features in man is the ability to search. You can use either of the following ways to search:

$ man -k keyword
or
$ apropos keyword

One more note on the man command. Most man pages are pretty long, and would scroll off your screen if they were displayed all at once. For this reason, man uses a pager like less or more to scroll the output. This can be confusing because the default pager for Solaris systems is more, and the default pager for Linux systems is less. The primary effect of this difference is that you must press 'q' to quit less, whereas more will automatically quit when you reach the end of the file it is paging for you. (Note: you can also use q to quit out of more instead of reading the whole file.) Contrary to the names used for the programs, less has more features than more, including hilighting of search terms, the ability to scroll your output with the arrow keys instead of just [Space] and 'b', and several other features we'll leave as an exercise for the reader to dig out with the man command. You can set the PAGER environment variable to the pager you would prefer to have man use.

University of Houston State of Texas Privacy and Policies Homeland Security Compact with Texans Reporting Copyright Infringement Contact U H Feedback Site Map Statewide Search U H System