On an average GNU/Linux system, way too many commands are available to ever remember them all, which is why learning how to use the help resources available on the system is important. This article provides a brief overview about the usage of –help option, help, man, info and (more important) what you can do with them.

–help

The fastest way to get an overview of how to use a command is by following the command with the –help option. Most commands will display a usage summary when using this option. The list of options that is shown in this way is of use mainly when you already possess a basic understanding of how to the command is used and you need a quick overview of the options available with the command.

touch --help

Example of –help usage with touch –help

Some commands might not honor that option and consider it erroneous. Fortunately, these commands will be so friendly to show an error message, displaying valid options for that particular command, meaning you’ll get what you needed anyway.

Man

Man is simply a text-based help system in Linux. The command’s name is short for manual, and its entries provide concise synopses of what a command, file, or other feature does.  When using the Linux command line, you will at some point consult man pages. Man is what makes working from the command line doable. If you do not know how a command is used, the man page of that command will provide valuable insight. For instance, to learn about man itself, you can type man man. The result will be a description of the man command.  To peruse the manual pages for a particular command or topic, you type man followed by the command or topic as an option. For example, to read about the export command, you would type man export at the prompt. If you wanted to learn more about the shell built-in (internal) commands, you would type man builtin at the prompt.

 

man man

Output of man man

 The man utility makes use of the less pager by default to display information. This program displays text one page at a time. Press the spacebar to go forward by one page, Esc followed by V to move backward by one page, the arrow keys or Shift + PageUp/PageDown to move up or down a line at a time, the slash (/) key to search for text, and so on.

When you’re done, you can press Q to exit less and the man page being displayed.  You aren’t stuck using the less pager with the man utility. You can modify the pager by using the -P option. For instance, if you decided to use the more pager instead to look up information on the uname command, you would type man -P /bin/more uname at the shell prompt.

The most important sections of the man page in general are at the bottom of the man page. Here you’ll find two important sections: In many cases there are examples; if there are no examples, there is always a “see also” section. This brings you to related man pages, which is useful if you have just not hit the right man page. To get to the bottom of the man page as fast as possible, use the G command. You can also type /example to search the man page for any examples.

 Occasionally, the problem arises where you can’t remember the exact name of a command to look up. The man utility has an option to help you here. You can use the -k option along with a keyword or two to search through the man pages. An alternative to man -k is apropos. They provide the same results. These commands looks in the summary of all man pages that are stored in the mandb database.

The returned information (shown as a partial listing above) can give you some clues as to your desired command name. Based on the information that man -k is giving you, you can probably identify the man page that you need to do whatever you want to do. Be aware that poor keyword choices may not produce the results you seek for man -k is not perfect; it searches only the short summary of each command that is installed. If your keyword is not in the summary, you’ll find nothing and get a “nothing appropriate” error message.

When using the man -k command, the mandb database is consulted. It can sometimes happen that  you are looking for something that should obviously be documented but you cannot find anything anyway and all you get is “nothing appropriate.” If that happens, you might need to update the man database. Doing that is easy: Just run the mandb command as root without any arguments. It will see whether new man pages have been installed and update the man database accordingly.

On some older Linux distributions, you may get no results from a man utility keyword search. This is most likely due to a missing whatis database. A short description of each man page is contained in the whatis database, and it is necessary for keyword searches. To create it or update it, type makewhatis at the prompt. You will need to do this as superuser, and it may take several minutes to run.  Linux man pages are organized into several sections.

[meta-linux@localhost ~]$ man -k bzmore

bzless [bzmore]      (1)  – file perusal filter for crt viewing of bzip2 compressed text

bzmore               (1)  – file perusal filter for crt viewing of bzip2 compressed text

bzmore [bzless]      (1)  – file perusal filter for crt viewing of bzip2 compressed text

[meta-linux@localhost ~]$

 

[meta-linux@localhost doc]$ apropos bzmore

bzless [bzmore]      (1)  – file perusal filter for crt viewing of bzip2 compressed text

bzmore               (1)  – file perusal filter for crt viewing of bzip2 compressed text

bzmore [bzless]      (1)  – file perusal filter for crt viewing of bzip2 compressed text

[meta-linux@localhost doc]$

Sometimes a single keyword has entries in several sections. For example, passwd has entries under  section 1 as well as section 5. Most of the time, man displays the lowest-numbered section’s entry. You can still force the result by preceding the section number with a keyword. If you try typing man 5 passwd, it returns information on the passwd file format rather than the passwd command.

Section 1 ==> Executable programs and shell commands

Section 2 ==> System calls provided by the kernel

Section 3 ==> Library calls provided by program libraries

Section 4 ==>Device files (usually stored in /dev)

Section 5 ==> File formats

Section 6 ==> Games

Section 7 ==> Miscellaneous (macro packages, conventions, and so on)

Section 8 ==> System administration commands (programs run mostly or exclusively by root)

Section 9 ==> Kernel routines

While using man -k to find specific information from the man pages, you’ll sometimes really get a lot of information. If that happens, it might help to filter down the results a bit by using grep. But if you want to do that, it is important that you understand what you are looking for exactly.

Info

Apart from the information that you’ll find in man, another system provides help about command usage. This is the info system. The basic purpose of info pages is the same as that for man pages. Most commands are documented in man, but some commands are documented only in the info system. Type info info to learn more on this system.  Some programs have moved away from man pages to info pages. If that is the case, the “see also” section of the manual page of that command will inform you that “The full documentation for [command] is maintained as a Texinfo manual.” If that happens, you can read the Info page using the command pinfo or info . Both commands work, but in pinfo , special items such as menu items are clearly indicated, which is why using pinfo is recommended.

info info

Output of info info

When working with info, take a look at the top line of the viewer. This shows the current position in the info document. Particularly interesting are the Up, Next, and Previous indicators which tell you how to navigate. info pages use a hypertext format so that you can move from section to section of the documentation for a program. Info pages are organized like web pages, which means that they are organized in a hierarchical way. To browse through that hierarchy, type n to go to the next page, p to go to the previous page, or u to move up in the hierarchy. In an info page, you’ll also find menus. Each item that is marked with an asterisk (*) is a menu item. Use the arrow keys to select a specific menu item. This brings you down one level. To get back up again, press u . This brings you back to the original starting point in the pinfo hierarchy.

Help

 There are also pages specifically for the built-in (internal) commands called the help pages. To read the help pages for a particular built-in command, type help command. For instance, to get help on the pwd command, type help pwd at the shell prompt. To learn more about how to use the help pages, type help help at the shell prompt.  The man pages, info pages, and help pages are usually written in a terse style. They’re planned as reference tools, not tutorials! They frequently assume basic familiarity with the command, or at least with Linux in general. For more tutorial information, you must look elsewhere, such in books or on the Web.

[meta-linux@localhost ~]$ help help

help: help [-dms] [pattern …]

    Display information about builtin commands.

    Displays brief summaries of builtin commands.  If PATTERN is

    specified, gives detailed help on all commands matching PATTERN,

    otherwise the list of help topics is printed.

    Options:

      -d        output short description for each topic

      -m        display usage in pseudo-manpage format

      -s        output only a short usage synopsis for each topic matching

        PATTERN

    Arguments:

      PATTERN   Pattern specifiying a help topic

    Exit Status:

    Returns success unless PATTERN is not found or an invalid option is given.

[meta-linux@localhost ~]$

Documentation

A third source of information consists of files that are sometimes copied to the /usr/share/doc directory. This happens in particular for services and larger systems that are a bit more complicated. You will not typically find much information about a command like ls , but some services do provide useful information in /usr/share/doc. Some services store very useful information in this directory, like rsyslog, bind, Kerberos, and OpenSSL. For setting up advanced services, you may need access to this information.

Hope you enjoyed learning GNU/Linux help utilities. Leave your comments and questions right below if you have any difficulties finding help, I will be very glad to help you out and learn at the same time. You can also ask for tutorials you would like to see. Do not forget to share and like! Go Linux!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s