man command is a built-in manual for using Linux commands. It allows users to view the reference manuals of a command or utility run in the terminal. The man page (short for manual page) includes a command description, applicable options, flags, examples, and other informative sections.
In this tutorial, you will learn to use the
man command in Linux.
- A machine running Linux
- Access to the command line
- An account with root privileges
Linux man Command Syntax
man command syntax is:
man [option] [section number] [command name]
option– the search result output.
section number– the section in which to look for the man page.
command name– the name of the command which man page you want to see.
man looks in all the available sections of the manual and shows the first match (even if the page exists in several sections). Providing a section number instructs the
man command to look in a specific section.
There are nine sections of the manual:
1. General commands: Commands used in the terminal.
2. System calls: Functions the kernel provides.
3. Library functions: Functions in program libraries.
4. Special files: Usually devices found in /dev and related drivers.
5. File formats and conventions: File formats like etc/passwd.
6. Games: Descriptions of commands that display database quotes.
7. Miscellaneous: Various descriptions, including macro packages and conventions, boot parameters, and others.
8. System administration commands: Commands mostly reserved for root.
9. Kernel Routines: Information about internal kernel operations.
How to Use man in Linux
In the terminal window, type
man followed by the Linux command name which man page you want to see.
The output is lengthy. Use the mouse scroll wheel, the up and down arrow keys, or the PgDn and PgUp keys to navigate through it.
After running the
man command, press H to see the help section and a table of possible keystrokes for navigating the output.
To exit, press Q.
The output of the command displays the available man page headings for the specified command.
The list of possible headings includes:
- Name: The name of the command.
- Synopsis: The command’s syntax.
- Configuration: Configuration details for a device.
- Description: A description of the command.
- Examples: Several examples demonstrating the use of the command.
- Defaults: The default functions of the command and how they can be overridden.
- Options: A list of options and flags that the command accepts.
- Exit Status: A list of possible exit status values for the command.
- Environment: A list and description of environment variables that affect the command.
- Files: A list of files used by the command.
- See also: Commands related to the described topic.
- Authors: The people who wrote or maintain the command.
- History: Command development history.
- Notes: Various notes, including permissions required, dependencies, etc.
- Bugs: Any known issues in this program version.
Note: Pages may contain more or fewer headings depending on the man page contents.
Look for man Pages
-f option displays all man pages that match the specified command name and states the sections in which the given command is present.
Use the following syntax:
man -f [command name]
The output is a list of results that match the search criteria. With multiple matches, the number next to the search result indicates the section.
Display man Pages From Specific Sections
To display the page from a specific section of a manual, use the syntax:
man [section number] [command name]
man 3 sleep
The output shows only the page from section 3 of the manual.
Display man Pages in a Browser
Man pages are long and sometimes difficult to scroll through to find the information you need. The
man command allows users to display man pages in a browser to find information easily.
To do so, follow these steps:
1. Make sure the groff package is installed. Run:
sudo apt-get install groff
2. Before calling the
man command, select a default browser. Run:
To use a different browser, replace
chromium-browser, or any other browser.
3. Use the
-H option to read the man page in a browser of your choice:
man -Hfirefox vmstat
-H option instructs groff to produce an HTML output and displays that output in a browser.
Display man Pages and Print Short Descriptions
-f option allows users to look up the man pages and prints out short descriptions of the specified command in the terminal. The syntax is:
man -f [command name]
Display All man Pages
-a attribute allows users to display all available intro manual pages contained in each section, one at a time.
man -a [command name]
Quit between successive displays or skip through them using Ctrl+C or Ctrl+D, respectively.
Search by Considering Input as a Regular Expression
-k option allows users to search the short command descriptions and manual page names for a specified keyword as a regular expression. The output shows any available matches.
The syntax is:
man -k [command name]
Display Location of man Pages
-w attribute shows the location of the manual page of the specified command. Adding the
-a option prints out the locations of all files matching the keyword.
The syntax is:
man -w [command name]
In this example, we used the
-a option to see the locations of all associated man pages.
Additionally, using the
-W option displays the location of the preformatted cat file. With the
-a option, it prints out the locations of all preformatted cat files matching the keyword.
To search for manual pages using case-sensitivity, use the
-I option. The syntax is:
man -I [command name]
man default setting is to ignore case when looking up manual pages. To go back to default settings and ignore case, use the
You now know how to use the
man command in Linux. Use the command to see user manuals for Linux commands, search for a specific keyword, or see all the entries in the manual.