Home » Linux » Shell » Linux Man Command

Linux man Command and Man Pages [Explanation/Examples]

This article describes the purpose and usage of the man command in Linux and other Unix-like operating systems.

Linux is a highly modular operating system, consisting of the core operating system (the Linux Kernel) and a collection of software packages that add functionality to it. These packages are generally individually maintained. Thus, each computer system will have different packages depending on what the user requires their system to do (for example, a graphic designer will have some drawing tools installed, whereas someone writing a novel may instead have a word processor installed.).

As no system is truly the same, each package provides its own documentation, which is installed along with the package – ensuring that you always have the information you need to use the software installed on your computer. This documentation is a manual page, which is added to a section of the system manual.

The man command displays the user manual for any terminal command on your system (assuming the developer has supplied it). It provides an organized set of instructions of exactly how a command should be used and often includes some handy examples.

man Command Syntax

Here’s the syntax for the man command:

man OPTIONS SECTION COMMAND

Note that:

  • OPTIONS should be a list of options from the below table
    • If no OPTIONS are supplied, the entire user manual for the given command will be displayed
  • SECTION should be the section of the manual you wish to search for the requested manual page
    • See the below table for commonly used SECTIONs
    • If not SECTION is supplied, entries from every section are displayed
  • COMMAND should be the name of the command you wish to view the user manual for
    • ‘No manual entry’ will be displayed if no user manual for the given command is found
  • By default, the less command is used to display the contents of the manual page
    • *** Use the arrow keys to navigate or press Q to quit the user manual while it is being displayed!***

Manual Sections

Different commands will have manual pages in different sections of the system manual:

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, e.g. /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]

Specifying a section will display only entries from that section of the user manual.

The manual pages contain their own sections, commonly split into NAME, SYNOPSIS, CONFIGURATION, DESCRIPTION, OPTIONS, EXIT STATUS, RETURN VALUE, ERRORS, ENVIRONMENT, FILES, VERSIONS, CONFORMING TO, NOTES, BUGS, EXAMPLE, AUTHORS, and SEE ALSO.

Common man Command Options

Here are some of the most commonly used man command options, straight from the user manual:

-a By default, man will exit after displaying the most suitable manual page it finds. This option forces man to display all the manual pages with names that match the search.
-f Display a short description from the manual page if available.
-k Search the short manual page descriptions for keywords and display any matches.
-i Ignore case when searching for manual pages (default).
-I Do not ignore case when searching for manual pages.
–wildcard Show all pages with any part of either their names or their descriptions matching each page argument using shell-style wildcards.
-P Specify which output pager to use. By default, man uses less, falling back to cat if less is not found or is not executable.

…And, of course, you can use the man command to view the user manual for the man command itself! Just run:

man man

…to see the full user manual and a full list of available options.

Linux man Command Examples

To view the most relevant manual page for a given command, type man followed by the command name:

man less

Above, the manual for the less command is displayed. Coincidentally, the less command is the tool used to display the man page on-screen.

The if option will display the sections a command is found in as well as a short description:

man -f mv

Above, the mv command is queried, resulting in the following output:

mv(1)                    - move files

…stating that the mv command is in section 1 and that it moves files.

To find out where the manual page for a command is stored, use the -w option:

man -w mv

…which will output:

/usr/share/man/man1/mv.1

The -k option will search all manuals, all sections, for any matches to the given string:

man -k mv

Conclusion

The man command really is great. If you’re offline or want a quick refresher on using a command, it’s invaluable.

SHARE:
Photo of author
Author
I'm Brad, and I'm nearing 20 years of experience with Linux. I've worked in just about every IT role there is before taking the leap into software development. Currently, I'm building desktop and web-based solutions with NodeJS and PHP hosted on Linux infrastructure. Visit my blog or find me on Twitter to see what I'm up to.

Leave a Comment