
Introduction
The man (manual) command is an important tool that provides detailed information about Linux commands and programs. It provides comprehensive documentation, including descriptions, options, usage examples, and related information about commands or a specific program.
This article explains how to use the man command in Linux to access and read manual pages.
man Command Syntax
Below is the basic man command syntax:
$ man [option] command_name
Within the above command, command_name sets the name of the command or program to view its manual page.
man Command Options
| Option | Description |
|---|---|
-a |
Displays all manual pages for a specific command. |
-k |
Search the short descriptions and manual page names for a specified keyword (equal to apropos). |
-f |
Display the manual page titles for the specified command (equal to whatis). |
-M |
Specifies a custom path to the manual pages. |
-P |
Specifies a pager command other than the default. |
-u |
Updates the database of manual pages. |
-w |
Displays the location of the manual page files. |
Practical Examples of the man Command
Read the manual page of a specific command.
console$ man ls
The above command displays the manual page for the
lscommand, which includes detailed information about its usage.Output:

Search for a command using a specific keyword in its description.
console$ man -k copy
The above command looks up a command's short description or manual page names with the keyword
copyand lists all related commands.Output:

Display manual page titles.
console$ man -f ls
The above command displays the titles of manual pages for the
lscommand with a brief description for each.Output:

View all the manual pages for a specific command.
console$ man -a intro
The above command displays all manual pages for the
introcommand.Output:

Display the location of manual page files.
console$ man -w ls
The above command outputs the path to the
lsmanual page.Output:

Use
manwith a custom pager command.console$ man -P cat ls
The above command uses
catinstead of the default pager to display thelsmanual page.Output:

Specify a manual page section to look up a specific command.
console$ man 5 passwd
The above command displays section 5 of the
passwdmanual page that includes the file format information.Output:

Navigating the Manual Pages
Use the following keyboard shortcuts to navigate and search through the manual page contents.
- Spacebar: Scroll down one screen at a time.
- b: Scroll up one screen at a time.
- Enter: Scroll down one line at a time.
- k: Scroll up one line at a time.
- /pattern: Search forward for a pattern.
- ?pattern: Search backward for a pattern.
- n: Repeat the last search in the same direction.
- N: Repeat the last search in the opposite direction.
- q: Quit the manual page viewer.
Understanding Manual Page Sections
Manual pages are divided into sections that include different types of information. Common sections include:
- 1: User commands.
- 2: System calls.
- 3: Library functions.
- 4: Special files (usually found in /dev).
- 5: File formats and conventions.
- 6: Games and screensavers.
- 7: Miscellaneous.
- 8: System administration commands.
Advanced Usage Scenarios
View the manual pages for library functions.
console$ man 3 printf
The above command displays the manual page for the
printffunction, which is part of the C standard library.Output:

Read the manual pages for system calls.
console$ man 2 open
The above command displays the manual page for the
opensystem call and provides information on how files are opened in the kernel.Output:

Use
manin scripts to display specific documentation information about commands.Create a new script file using a text editor such as Nano
console$ nano my_script1.sh
Add the following contents to the file.
bash#!/bin/bash echo "Displaying the manual page for the 'ls' command:" man ls
Enable execute permissions on the file.
console$ chmod +x my_script1.sh
Run the script
console$ ./my_script1.sh
The above script displays the manual page for the
lscommand when executed.Output:

Combine the
mancommand withgrepto search pages.console$ man ls | grep "list"
The above command pipes the manual page output for the ls command to grep and searches for lines that contain the string list.
Output:

Update the manual pages database.
console$ sudo mandb
The above command updates the database of all manual pages to ensure new or removed pages are available in the search results.
Conclusion
You have used the man command to search for documentation and command usage pages. For more information about the man command, run man man to view the command's manual page.