
man Command in Linux
The man command in Linux is an essential tool for anyone working with Unix-like operating systems. It stands for "manual" and provides detailed documentation about commands, system calls, library functions, and other aspects of the system.
Table of Contents
Here is a comprehensive guide to the options available with the man command −
- Understanding man Command
- Syntax of man Command
- Common Sections in Man Pages
- man Command Options
- Examples of man Command in Linux
- Advanced Features of man Command
Understanding man Command
The man command displays the manual pages (man pages) for commands and other system components. These pages contain detailed information about the usage, options, and examples of the command or function in question. The man command is a vital resource for learning about the capabilities and syntax of various commands.
Syntax of man Command
The basic syntax for the man command is −
man [options] [command]
Without any options, the command displays the manual page for the specified command.
Common Sections in Man Pages
Man pages are divided into several sections, each covering different types of information. Here are the most common sections −
- User Commands − Commands that can be executed by users.
- System Calls − Functions provided by the kernel.
- Library Functions − Functions provided by system libraries.
- Special Files − Files found in /dev.
- File Formats and Conventions − Descriptions of various file formats.
- Games and Screensavers − Games and screensavers available on the system.
- Miscellaneous − Various other topics.
- System Administration Commands − Commands used by system administrators.
- Kernel Routines − Functions and routines used by the kernel.
man Command Options
Here are some of the most commonly used options with the man command −
Options | Description |
---|---|
-a | Display all matching manual pages. |
-k | Search the short descriptions and manual page names for the keyword. |
-f | Display the manual page descriptions. |
-w | Print the location of the manual page files. |
-P | Specify the pager program. |
-C | Specify the configuration file. |
-s | Specify the section number. |
-t | Format the manual page for printing. |
-u | Update the database of manual pages. |
-M | Specify an alternate set of man pages. |
-l | Display local manual pages. |
Examples of man Command in Linux
Let's explore some practical examples to understand how to use the man command effectively.
Display the Manual Page for a Command
This command displays the manual page for the ls command, providing detailed information about its usage, options, and examples −
man ls

Search for a Keyword in Man Pages
This command searches the short descriptions and manual page names for the keyword "copy" and displays a list of matching entries −
man -k copy

Display the Manual Page Description
This command displays the manual page description for the ls command, providing a brief summary of its purpose −
man -f ls

Display All Matching Manual Pages
This command displays all matching manual pages for the keyword "intro," allowing you to cycle through each one −
man -a intro

Specify the Section Number
This command displays the manual page for the passwd file format, which is found in section 5 of the manual −
man 5 passwd

Print the Location of Manual Page Files
This command prints the location of the manual page files for the ls command −
man -w ls

Specify an Alternate Set of Man Pages
This command specifies an alternate set of man pages located in /usr/local/man and displays the manual page for the ls command from that location −
man -M /usr/local/man ls

Specify the Pager Program
This command specifies the less program as the pager for displaying the manual page for the ls command −
man -P less ls

Format the Manual Page for Printing
This command formats the manual page for the ls command for printing and saves it as a PostScript file named ls.ps −
man -t ls > ls.ps

Update the Database of Manual Pages
This command updates the database of manual pages, ensuring that the latest information is available −
man -u

Advanced Features of man Command
In addition to the basic options and examples, the man command provides advanced features that can be useful in specific scenarios. Let's explore some of these features with practical examples.
Viewing Local Manual Pages
This command displays a local manual page located at the specified path. The -l option allows you to view manual pages that are not installed in the standard directories −
man -l /path/to/local/manpage.1

Using Environment Variables
This command sets the MANPATH environment variable to include additional directories for manual pages. The man command will search these directories when displaying manual pages −
export MANPATH=/usr/local/man:/usr/share/man man ls

Searching for Commands by Description
This command searches the manual page descriptions for the keyword "copy" and displays a list of matching entries. The apropos command is equivalent to man -k −
apropos copy

Displaying Manual Pages for System Calls
This command displays the manual page for the open system call, which is found in section 2 of the manual −
man 2 open

Displaying Manual Pages for Library Functions
This command displays the manual page for the printf library function, which is found in section 3 of the manual −
man 3 printf

Displaying Manual Pages for Special Files
This command displays the manual page for the tty special file, which is found in section 4 of the manual −
man 4 tty

Displaying Manual Pages for File Formats
This command displays the manual page for the crontab file format, which is found in section 5 of the manual −
man 5 crontab

Displaying Manual Pages for Games
This command displays the manual page for the nethack game, which is found in section 6 of the manual −
man 6 nethack

Displaying Manual Pages for Miscellaneous Topics
This command displays the manual page for the regex topic, which is found in section 7 of the manual −
man 7 regex

For more detailed information, you can refer to the official man documentation.
Conclusion
The man command is an essential tool for anyone working with Linux systems, providing detailed documentation about commands, system calls, library functions, and other aspects of the system.
By mastering the various options and examples provided in this tutorial, you'll be well-equipped to leverage the full power of the man command in your daily tasks. Whether you're learning about new commands, troubleshooting issues, or configuring your system, the man command is a versatile and invaluable resource in your Linux toolkit.