How to effectively use Man Pages under Linux

The online Reference Manual (man) pages provide detailed descriptions and usage of the commands. You can use the man command to display the man page entry that explains a given command. The syntax of the man command is as follows.

$ man command
$ man option command
$ man option filename

Displaying the Man Pages

For example, display the man pages for the uname command using the man command.

NAME(1)                                                               User Commands                      
                                         UNAME(1)
NAME
       uname - print system information
SYNOPSIS
       uname [OPTION]...
DESCRIPTION
       Print certain system information.  With no OPTION, same as -s.
       -a, --all
              print all information, in the following order, except omit -p and -i if unknown:
       -s, --kernel-name
              print the kernel name
       -n, --nodename
              print the network node hostname
       -r, --kernel-release
              print the kernel release
....

Scrolling Through the Man Pages

The following table lists the keyboard commands for scrolling through the man pages.

Keyboard Command Action
Space bar Displays the next screen of a man page
Return Displays the next line of a man page
b Moves back one full screen
/pattern Searches forward for a pattern
n Finds the next occurrence of a pattern after you have used /pattern
h Provides a description of all scrolling capabilities
q Quits the man command and returns to the shell prompt

Searching the Man Pages

There are two ways to search for information in the man pages:

  • Searching by section
  • Searching by keyword

Searching the Man Pages: By Section

The online man page entries are organized into sections based on the type or usage of the command or file. For example, Section 1 contains user commands, and Section 4 contains information about various file formats. To look up a specific section of the man page, use the man command with the -s option, followed by the section number, and the command or file name.

 $ man -s number command
or
$ man -s number filename

The table below shows the section numbers of the manual followed by the types of pages they contain.

Section Number Description
1 Executable programs or shell commands
2 System calls (functions provided by the kernel)
3 Library calls (functions within program libraries)
4 Special files (usually found in /dev)
5 File formats and conventions eg /etc/passwd
6 Games
7 Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)
8 System administration commands (usually only for root)
9 Kernel routines [Non standard]

The bottom portion of a man page, titled ‘SEE ALSO‘, lists other commands or files related to the man page. The number in parentheses reflects the section where the man page is located.

Searching the Man Pages: By Keyword

When you are unsure of the name of a command, you can use the man command with the -k option and a keyword to search for matching man page entries.

$ man -k keyword

The man command output provides a list of commands and descriptions that contain the specified keyword. For example, using the man command, view commands containing the syslog keyword.

# man -k syslog
logger (1)           - a shell command interface to the syslog(3) system log module
rsyslog.conf (5)     - rsyslogd(8) configuration file
rsyslogd (8)         - reliable and extended syslogd
syslog (2)           - read and/or clear kernel message ring buffer; set console_loglevel
syslog (3)           - send messages to the system logger
syslog (3p)          - control system log
syslog.h (0p)        - definitions for system error logging
vsyslog (3)          - send messages to the system logger
Related Post