Updated April 14, 2023
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)
- Games
- 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]
Syntax
$man [OPTION] [COMMAND NAME]
OPTION
It displays the whole manual page of a particular command.
Syntax
$ man [COMMAND NAME]
Example
$ man printf
Using this command simply returns the manual pages of the printf command.
Output:
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.
Syntax
$ man [command/tool name]
Example
$ 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.
Syntax
$ man [section num] [command name]
Example
$ man 2 intro
Output:
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.
Syntax
$ man -f [command name]
Exa mple
$ man -f ls
Output:
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.
Syntax
$ man –a [command name]
Example
$ man -a intro
Output:
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.
Syntax
$ man -k [command name]
Example
$ man -k cd
Output:
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.
Syntax
$ man -w [command name]
Example
$ man -w ls
Output:
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.
Syntax
$ man -H [browser command] [command name]
Example
$ 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.
Syntax
$ man -I [command name]
Example
$ man -I printf
–no-subpages OPTION
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.
Example
$ man -aw git diff
The above command displays the following manual page.
/usr/share/man/man1/git-diff.1.gz
To disable this behaviour, we have to use the option –no-subpages.
for example:
man –aw –no-subpages git diff
the above command will show the manual pages for both git and diff.
Output:
/usr/share/man/man1/git.1.gz
/usr/share/man/man3/git.3pm.gz
/usr/share/man/man1/diff.1.gz
-p OPTION
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.
-r OPTION
If the pager used is the recent form of less, then the man tries to set its prompt and some more reasonable options.
Example
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.
-E OPTION
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.
EXIT STATUS
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.
FILES
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
Recommended Articles
We hope that this EDUCBA information on “Linux man Command” was beneficial to you. You can view EDUCBA’s recommended articles for more information.