Using man to Get Help

The most important source of information for using commands that are available on your Linux system is man. man is short for the system programmer's manual. In the past, these were books in which all parts of the Unix operating system were documented. This structure of different books (nowadays called sections) is still present in the man command; therefore, you will now find a list of the available sections and the type of help you can find in these sections:

0: Section 0 contains information about header files. These are files that are typically in /usr/include and contain generic code that can be used by your programs.

1: Executable programs or shell commands. For the user, this is the most important section. Usually, all commands that can be used by end users are documented here.

2: System calls. As an administrator, you will not use this section frequently. The system calls are functions that are provided by the kernel. This is interesting if you are a kernel debugger; normal administrators, however, don't need this information.

3: Library calls. A library is a piece of shared code that can be used by several different programs. Typically, you don't need the information here to do your work as a system administrator.

4: Special files. In here, the device files in the directory /dev are documented. It can be useful to use this section to find out more about how specific devices work.

5: Configuration files. Here you'll find the proper format you can use for most configuration files on your server. If, for example, you want to know more about the way /etc/passwd is organized, use the entry for passwd in this section by issuing the command man 5 passwd.

6: Games. On a modern Linux system, this section contains hardly any information.

7: Miscellaneous. Contains some information on macro packages used on your server.

8: System administration commands. This section does contain important information about the commands you will use frequently as a system administrator.

9: Kernel routines. This is documentation that isn't even installed standard and optionally contains information about kernel routines.

So, the information that is important for you as a system administrator is in sections 1, 5, and 8. Most of the time you don't need to know anything about these different sections, but sometimes an entry can exist in more than one section. For example, there is information on passwd in section 1, but also in section 5. If you would just use man passwd, man would show the content of the first entry it finds. If you want to make sure that all the information you need is displayed, use man -a <yourcommand>, which makes sure man browses all sections to see whether it can find anything about <yourcommand>. If you know beforehand what section to look in, specify the section number as well, as in man 5 passwd, which will open the passwd item from section 5 directly.

The basic structure for using man is to type man followed by the command you want information about. For example, type man passwd to get more information about the passwd item. This will show a man page, as shown in Figure 4-3.


rial Tabs Help passwd(1)

passwd - change user password


passwd [-D binddnl[—n mini[-x max][-w warn][-1 inact] account passwd [-D binddn] {-1|-u|-d|-S[-a]|—e} name —stdin [account]


passwd changes passwords for user and group accounts. While an administrator may change the password for any account or group, a normal user is only allowed to change the password for their own account, passwd also changes account information, such as the full name of the user, their login shell, password expiry dates and intervals or disable an account.

passwd is written to work through the PAM API. Essentially, it initializes itself as a "passwd" service and utilizes configured "password" modules to authenticate and then update a user's password.

A sample /etc/pam.d/passwd file might look like this:

auth account password password session required nullok required required nullok required nullok \

usefirstpass useauthtok required

Password Changes

If an old password is present, the user is first promted for it and the password is compared agaisnt the stored one. This can be changed, depending which PAM modules are used. An administrator is permitted to bypass this step so that forgotten passwords may be changed.

Manual page passwd(1) line 1

Figure 4-3. All man pages are structured in the same way.

Each man page consists of the following elements:

Name: This is the name of the command. It describes in one or two lines what the command is used for.

Synopsis: Here you can find short usage information about the command. It will show all available options and indicate whether an option is optional (it will be between square brackets) or mandatory (it will not be between brackets).

Description: The description gives the long description of what the command is doing. Read it to get a complete picture of the purpose of the command.

Options: This is a complete list of all options that are available. It documents how to use all of them.

Files: This section provides a brief list of the files, if any, that are related to the command you want more information about.

See also: A list of related commands.

Author: The author and also the mail address of the person who wrote the man page.

Now man is a useful system to get more information about how to use a given command. So far, it is useful only if you know what the name of the command is that you want to have more information about. If you don't have that information and need to locate the proper command, you will like man -k. The -k option allows you to locate the command you need by looking at keywords. This will often show a long list of commands from all sections of the man pages. In most cases, you don't need to see all that information; the commands that are relevant for the system administrator are in sections 1 and 8, and sometimes when you are looking for a configuration file, you should browse section 5. Therefore, it is good to pipe the output of man -k through the grep utility, which you can use for filtering. For example, use man -k time | grep 1 to show only lines from man section 1 that have the word time in the description.

Was this article helpful?

0 0

Post a comment