Linux Man Command
The "man" is a short term for manual page. In unix like operating systems such as linux, man is an
interface to view the system's reference manual.
A user can request to display a man page by simply typing man followed by a space and then
argument. Here its argument can be a command, utility or function. A manual page associated with
each of these arguments is displayed.
If you will provide a section number in the command, then man will be directed to look into that
section number of the manual and that section page will be displayed. And if not, then by default it
will display the first page and you have to go through the entire sections in a pre-defined manner.
man Command in Linux
Introduction to man
man is a built-in manual for utilizing Linux commands. It permits users to access the reference manual of a utility or a command to execute in the terminal. The man command contains the command description, examples, flags, applicable options, and other informative elements.
- A root privilege account
- Command line access
- A machine with running Linux
We'll read about section number in this tutorial.
Syntax of man:
But generally [option(s)] are not used. Only keyword is written as an argument.
This command will display all the information about 'ls' command as shown in the screen shot.
By default, the man command searches for every available component of the manual and displays the initial match (even when the page is available in many sections). Giving a section number addresses the man command to search in a particular section.
Nine manual sections are listed and explained as follows:
- General commands: It shows the commands that are utilized in the terminal.
- Library functions: It shows the functions within the program libraries.
- System calls: These show the functions that are provided by the kernel.
- Special files: Devices are usually found in the /dev directory and corresponding drivers.
- Games: It shows the command descriptions that show database quotes.
File formats and conventions: It shows the file formats such as etc/passwd.
- Miscellaneous: various descriptions, such as boot parameters, macro conventions and packages, and others.
- Kernel routines: It displays information about the internal operations of the kernel.
- System administration commands: Most commands are reserved for root.
How to use the man command in Linux?
- Type the man command followed by the name of the Linux command which man page we wish to see on the terminal screen.
- The result is lengthy. We can use the scroll wheel of the mouse, the up and down keys, or the PgUp and PgDn keys to operate through it.
- We can click the H button to find the help section and a possible keystroke table to navigate the output after executing the man command.
- We can press the Q button to exit.
- The command output shows the available heading of the man page for the named command.
The following are the possible heading list:
- Name: It shows the command's name.
- Synopsis: It shows the syntax of the command.
- Examples: In this heading, many examples demonstrate the command usage.
- Configuration: It shows the configuration information for a device.
- Defaults: They represent the command's default function and how they can be controlled.
- Options: They show a list of flags and options that the command takes.
- Exit status: It shows the list of exit status values possible for a command.
- Files: They show a file list utilized by the command.
- Environment: It displays the description and list of environment variables that influence the command.
- See also: It represents the commands corresponding to the specified topic.
- History: It shows the history of the command development.
- Authors: This heading shows the person who wrote and managed the command.
- Notes: This heading shows many notes, including dependencies, permission required, etc.
- Bugs: This heading shows the known issues in the program version.
Important: Pages may include fewer or more headings relying on the contents of the man page.
How Output is Displayed in Command Shell
man display its output through pager. A pager is a program that displays its output one screenfull at a time, means whole text doesn't appear at once and there is no option to scroll down the page.
A colon at the bottom displays end of the on-screen page. To go to the next page you can use ?space bar' or 'f' and to go backward page you can use 'b'.
To exit from the on-screen page use 'q' and you will be directed to the shell program. And for help press 'h'.
Sections in the man Page:
man page is divided into different sections. Each section is divided based up on a particular topic.
The man pages have a number written in the parentheses after the command. These number represent the section number. In the above picture, you can see LS(1) at the top, which shows that it is from section 1.
As I stated earlier, if you will mention a particular section number then your man page will be directed to that section. Or else, you have to go through the whole sections in a pre-defined manner to go to your desired section.
- Executable programs and shell commands
- System calls
- Library calls
- Special files
- File formats and conventions
- System administration commands
- Kernel routines
n. Tcl/Tk (a programming language)
Syntax for a particular section:
|List all available sections of a command.
|To view all man pages of a command.
|sman -k (apropos)
|Shows a list of results in man page containing a keyword match.
|It displays description from manual page if available.
|Used to determine location of a man page
|It shows the entire command manual.
|As the manual is categorized into two or more sections, the section-num option is applied to show only a specific manual section.
|This option is used to return the location where the manual page of a specified command is available.
|This option takes the command case-sensitive.
|Normally, this option is issued as the initial option and resets the behavior of the man command to its default.
|This option prints the debug details.
|--config-file=file, -C file
|We can use this file for user configuration instead of the default of ~/.manpath.
|This option activates warnings using groff. It may be used to implement sanity checks on the manual page's source text. The warnings option is a comma-isolated warning name list. Mac is the default if it isn't supplied.
|It finds text on every manual page. It's a brute-force search. We should define a section to decrease the page numbers that require to be searched.
|It enables local mode. It formats and shows the files of the local manual rather than finding them from the manual collection of the system.
|--location, --path, --where, -w
|This option does not show the manual page but prints the source nroff file's location that would be edited. It shows the location of every source file that is the same as the search criteria if the -a flag is also used.