Categories
Design

How to create a man page on 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.

Displaying the Man Pages

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

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.

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.

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.