man is the system’s manual pager. The man command in Linux is an interface to the on-line reference manuals. It is best place to understand any command in Linux. So, lets see how to use man command in Linux?
Syntax
$man <argument>
Example
$man ls
will display the manual page for ls command
Description
A manual page has 9 sections. Each section contains pages of different types of arguments like command, system calls, library functions etc. The table below shows the section number along with the type of pages they contain.
Section | Content Type |
1 | Shell Commands e.g., cat, ls, pwd, passwd. ($man cat) |
2 | System calls e.g., fork, read, write. ($man 2 fork) |
3 | Library functions e.g, printf, scanf. ($man $printf) |
4 | Special files found in /dev e.g., random, tty ($man 4 random) |
5 | File formats e.g., /etc/passwd ($man 5 passwd) |
6 | Games e.g., intro ($man 6 intro) |
7 | Miscelleneous e.g., groff ($man 7 groff) |
8 | System Admin commands e.g., mkfs, mcs $man 8 mkfs) |
9 | kernel Routines |
You might notice that passwd is used in example for section 1 and section 5. passwd is a command which is used to set or change user password. For this the manual page is in section 1 so we write
$man 1 passwd
or simple
$man passwd
But there is a /etc/passwd file which contains the details about all the users in the system. To manual page for this passwd file is in section 5, so we write
$man 5 passwd
Navigating a man Page in Linux
The following keys can be used to navigate through a man page
Key | Use |
Spacebar | Scroll down one page |
PageDown | Scroll down one page |
PageUp | Scroll up one page |
DownArrow | Scroll down one line |
UpArrow | Scroll up one line |
d | Scroll down one-half page |
u | Scroll up one-half page |
/string | Search forward for string in page |
n | Repeat previous search forward in man page |
N | Repeat previous search backward in man page |
g | Go to start of manual page |
G | Go to end of manual page |
q | Exit man page |