Introduction to Linux man Command
The man stands for manual. The man command displays the user manual of any command that we run on the terminal. In this topic, we are going to learn about Linux man Command. It displays the command details such as NAME, SYNOPSIS, OPTIONS, DESCRIPTION, EXIT STATUS, RETURN VALUES, FIL, ERRORS VERSIONS, AUTHORS, EXAMPLES.
- Every manual can be divided into the following sections:
- Executable programs or shell commands
- System calls (It contains functions provided by the kernel)
- Library calls (It contains functions within program libraries)
- Special files (usually found in /dev)
- File formats and conventions e.g./etc/passwd
- Miscellaneous (including macro packages and conventions), e.g. man (7), Groff(7)
- System administration commands
- Kernel routines [Non-standard]
$man [OPTION] [COMMAND NAME]
It displays the whole manual page of a particular command.
$ man [COMMAND NAME]
$ man printf
Using this command simply returns the manual pages of the printf command.
How to Use Man Command in Linux?
Using man command is very simple. Just type the command with the name of the tool whose user manual you want to access.
$ man [command/tool name]
$ man ls
How to Display Manual Pages from Specific Sections?
All available manual pages are divided into multiple sections. Some sections contain man pages entries for the same name. Man command allows you to access man pages from a specific section directly. To do that, just type the section number before the command name.
$ man [section num] [command name]
$ man 2 intro
How to Search for Manual Pages and Print Short Descriptions?
We can’t remember the section number for manual entries for the same name.
To overcome that problem, we have a command option –f that displays all the manual pages that match the input.
$ man -f [command name]
$ man -f ls
How to Display All Manual Pages for Input?
If you want to display all the manual pages one by one corresponding to a particular input, you can do that by simply using the –a command.
$ man –a [command name]
$ man -a intro
The above output is produced In the system for the command. You can move through the pages for reading by pressing the enter key. You can skip pages by pressing ctrl – D. you can quit by clicking the Ctrl – C.
How to Search Considering Input as A Regular Expression?
This command enables you to search and list manual pages considering input as a regular expression. For this, you have to use the –k command option.
$ man -k [command name]
$ man -k cd
In the above example, the command cd is searched in all the manual pages by considering it as a regular expression and returns the manual pages with the section numbers in which it is found.
How to Display Location of Manual Pages?
If you want to know only the location of manual pages, you can use the –w command.
$ man -w [command name]
$ man -w ls
In the above example, the location of the ls command is displayed.
How to Display Manual Pages on Web Browser?
You can use the –H command option to display manual pages on the web browser.
$ man -H [browser command] [command name]
$ man -Hfirefox printf
How to Make Man Command Case Sensitive?
The man command, by default, ignores the case while searching for man pages. However, if you want to enable case sensitivity, you can use the –I command option.
$ man -I [command name]
$ man -I printf
Naturally, a man attempts to decipher sets of manual page names given on the direction line proportional to a solitary manual page name containing an underscore or hyphen.
$ man -aw git diff
The above command displays the following manual page.
To disable this behaviour, we have to use the option –no-subpages.
man –aw –no-subpages git diff
the above command will show the manual pages for both git and diff.
This option determines which pager to be utilized. Naturally, man utilizes pager – s. this choice supersedes the environment variable $manpager, which thus abrogates the environment variable $pager.
If the pager used is the recent form of less, then the man tries to set its prompt and some more reasonable options.
Manual page name (sec) line x
Here the sec specifies the section, and the name indicates the name of the manual page. And x denotes the number of the current line. This is done by the environment variable $less.
This option generates the output for a character encoding other than the default. For backward compatibility encoding such as latin1, ascii, or utf8 as well as a true character encoding such as UTF-8.
When man terminates, it returns one of the following exit status.
0 – It will be returned upon successful program execution.
1 – It will be returned if there is a usage, syntax, or configuration file error.
2 – It will be returned if there is an operational error.
3 – It will be returned if a child process returned a non-zero exit status.
16 – It will be returned if pages, files or keyword searched for doesn’t exist or was not matched.
The man uses the following files:
/usr/share/man – Global manual page hierarchy
/etc/manpath.config – the man –db configuration file.
/usr/share/man/index.(bt|db|dir|pag) – Traditional global index database cache
/usr/cache/man/index.(bt|db|dir|pag) – FHS compliant global index database cache.
OTHER GENERAL OPTIONS
-h, –help – print the help message and then exit.
-v, –version – print the version message and then exit.
-c file, –config-file=file – use configuration file file instead of the default path of ~/.manpath
-d, –debug – print the debugging information.
-D, –default – it sets the man’s behaviour to its default
This is a guide to Linux man Command. Here we have discussed the man command and its usage. Man is an important command that users should know. You may also have a look at the following articles to learn more –