The man command is used to format and display the man pages. The man pages are a user manual that is by default built into most Linux distributions It provide extensive documentation about commands and other aspects of the system, including configuration files, system calls, library routines and the kernel (i.e., the core of the operating system)
Syntax:
man [options] keyword/name
man is most commonly used without any options and with only one keyword. The keyword is the exact name of the command or other item for which information is desired. For example, the following provides information about the ls command (which is used to list the contents of any specified directory):
$ man ls
Following are different options can be used with man command:
The Whatis and Apropos Commands
During your Linux exploration, it sometimes happens that you forget a command or two or misremember what it does. Luckily, Linux takes this into consideration and has a solution to help retrieve those commands that have escaped into the forgettery.
Whatis Command
Whatis is a command that's bound to come in handy, especially while you're learning Linux. By typing "whatis" followed by a command, Linux returns the first line of the Man-page (manual page) for that command. Here's an example to show you what the "cp" command does:
$ whatis cp
This returns:
cp (1) - copy files and directories
The command is listed followed by a number in parentheses. The number refers to the section of the man-pages (manual pages) that the command can be found in.
For the command ifconfig:
$ whatis ifconfig
ifconfig (8) - configure a network interface
If you wanted more information about one of the commands, then you need to use man command.
Apropos Command
Linux knows so many commands, it's impossible to remember them all. Imagine you know only a part of the name or description of a command. Say for example, you remember "zip," but not the complete command.
You can use the apropos command to find Linux commands that are related to one or more keywords. As i mentioned, if you remember only "zip" word then you can type:
$ apropos zip
which will write out a table containing all Linux commands that include "zip" in the command name or in the brief description provided in the Name section of the man page of the command.
Syntax:
man [options] keyword/name
man is most commonly used without any options and with only one keyword. The keyword is the exact name of the command or other item for which information is desired. For example, the following provides information about the ls command (which is used to list the contents of any specified directory):
$ man ls
Following are different options can be used with man command:
C config_file | Specify the configuration file to use; the default is /etc/man.config. |
M path | Specify
the list of directories to search for man pages. Separate the directories
with colons. An empty list is the same as not specifying -M at all. |
a | By
default, man will exit after displaying the first manual page it finds. Using
this option forces man to display all the manual pages that match name, not just the first. |
c | Reformat
the source man page, even when an up-to-date cat page exists. This can be meaningful if the cat page was formatted for a screen with a different number of columns, or if the preformatted page is corrupted. |
d | Don't actually display the man pages, but do print gobs of debugging information. |
D | Both display and print debugging info. |
f | Equivalent to whatis. |
F or --preformat | Format only - do not display. |
h | Print a one-line help message and exit. |
k | Equivalent to apropos. |
K | Search
for the specified string in *all* man pages. Warning: this is probably very
slow! It helps to specify a section. |
The Whatis and Apropos Commands
During your Linux exploration, it sometimes happens that you forget a command or two or misremember what it does. Luckily, Linux takes this into consideration and has a solution to help retrieve those commands that have escaped into the forgettery.
Whatis Command
Whatis is a command that's bound to come in handy, especially while you're learning Linux. By typing "whatis" followed by a command, Linux returns the first line of the Man-page (manual page) for that command. Here's an example to show you what the "cp" command does:
$ whatis cp
This returns:
cp (1) - copy files and directories
The command is listed followed by a number in parentheses. The number refers to the section of the man-pages (manual pages) that the command can be found in.
For the command ifconfig:
$ whatis ifconfig
ifconfig (8) - configure a network interface
If you wanted more information about one of the commands, then you need to use man command.
Apropos Command
Linux knows so many commands, it's impossible to remember them all. Imagine you know only a part of the name or description of a command. Say for example, you remember "zip," but not the complete command.
You can use the apropos command to find Linux commands that are related to one or more keywords. As i mentioned, if you remember only "zip" word then you can type:
$ apropos zip
which will write out a table containing all Linux commands that include "zip" in the command name or in the brief description provided in the Name section of the man page of the command.