Using man to get help in Linux and Unix
Lawrence Abrams
- November 10, 2005
- Read 50,567 times
Table of Contents
Many users who try Linux for the first time can get confused easily as their is no readily apparent help system available to them. As Windows programs are typically graphical in nature, it is not too hard to find the help menu for that particular program. Linux, on the other hand, has thousands of very useful programs that are run from the command line and therefore it may not be easy to find the help for that particular programs. Thankfully for us, developers created the program called man. Man, which stands for manual, is a program that can be used to view the help or manual page for the thousands of individual programs found in Linux or Unix.
For the most part, but not always, when a program in Linux/Unix is developed the developer will also create a separate man page file that contains the manual for that particular program or command. When the program is installed, the installer will also install the man page that was included into the proper location so that you can easily read the manual page as needed. This tutorial will provide a basic overview of how to use man to see the manual, or help pages, for a particular program.
For this tutorial we teach you how to use man within the console or X-Windows Terminal program. If your *nix computer starts up automatically into X-Windows you will need to find the Terminal application and run it. This will present you with a small box with a prompt that you can type commands in. If your computer boots directly into the console, then you simply need to log in, and use the console for the rest of this tutorial.
Now that you are at a prompt, lets start learning how to use man. At your prompt type the following (please note for these exercises my prompt may look different than yours):
man
When you type man, without any arguments, and press enter you will see something like this:
$ man |
The reason you received this response is because man always requires an argument in order to work. For most purposes, this argument will generally be the name of the program. Now that we know this, lets look up the manual page for a popular command line program, the program mkdir. To see the manual page for mkdir we would type the following and press enter:
man mkdir
After you press enter, the man command will search for the manual page corresponding to mkdir and display it. So after typing that command you would see something like this:
$ man mkdir MKDIR(1) User Commands MKDIR(1)
NAME
SYNOPSIS
DESCRIPTION -Z, --context=CONTEXT (SELinux) set security context to CONTEXT Mandatory arguments to long options are mandatory for short options too.
-m, --mode=MODE
-p, --parents
-v, --verbose --help display this help and exit
--version
AUTHOR
REPORTING BUGS
COPYRIGHT
SEE ALSO info coreutils mkdir should give you access to the complete manual. mkdir (coreutils) 5.2.1 February 2005 MKDIR(1) $ |
As you can see the manual page for mkdir has extensive information. It tells you what the program does, the syntax for the command, the arguments that can be used with the command, who to report bugs found when using the program, and the copyright information for the program. With this information you should have no problem now seeing the manual for the myriad of *nix commands available.
How to search the man pages for a particular word or phrase
Sometimes you need help with a particular file or program and are unsure exactly which manual page to look up. Thankfully there is a argument that you can use with man that will allow you to search through all the man pages for a particular keyword or phrase. This argument is the -K argument. The syntax for this command is the following:
man -K keyword
So for example, lets say that you wanted to search for all manual pages that contained the word fstab, you would type:
man -K fstab
This would then return a list of manual pages that contain that word and give you the option to view it (Y), skip it (N), or quit the search (Q). To view one of the matches simply press the y button and that particular manual page will show.
Now that you know how to view the manual pages of *nix commands using man, get out there and explore your operating system. There are many different commands that will be useful to know. A very popular manual being intro; man intro. Man also can be fun. Try some of these man commands for some hidden surprises (may not work on all linux distributions):
man c
man poll (look in the warning section)
man sex
And if worse comes to worse, and you still need help using man, you can always type the command man man and press enter :)
As always, if you have any questions please feel free to ask them in the Linux Forum.
--
Lawrence Abrams
Bleeping Computer: Linux Tutorials
BleepingComputer.com: Computer Help & Tutorials for the beginning computer user.