man command in Linux with Examples

man command in Linux is used to display the user manual of any command that we can run on the terminal. It provides a detailed view of the command which includes NAME, SYNOPSIS, DESCRIPTION, OPTIONS, EXIT STATUS, RETURN VALUES, ERRORS, FILES, VERSIONS, EXAMPLES, AUTHORS and SEE ALSO.

Every manual is divided into the following sections:

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

Syntax :



$man [OPTION]... [COMMAND NAME]...

Options and Examples

1. No Option: It displays the whole manual of the command.

Syntax :

$ man [COMMAND NAME]

Example:

$ man printf

Output:

In this example, manual pages of the command ‘printf‘ are simply returned.

2. Section-num: Since a manual is divided into multiple sections so this option is used to display only a specific section of a manual.

Syntax :

$ man [SECTION-NUM] [COMMAND NAME]

Example:

$ man 2 intro

Output:


In this example, the manual pages of command ‘intro‘ are returned which lies in the section 2.

3. -f option: One may not be able to remember the sections in which a command is present. So this option gives the section in which the given command is present.

Syntax:

$ man -f [COMMAND NAME]

Example:

$ man -f ls

Output:

In this example, the command ‘ls‘ is returned with its section number.

4. -a option: This option helps us to display all the available intro manual pages in succession.

Syntax:


$ man -a [COMMAND NAME]

Example:

$ man -a intro

Output:

In this example you can move through the manual pages(sections) i.e either reading(by pressing Enter) or skipping(by pressing ctrl+D) or exiting(by pressing ctrl+C).

5. -k option: This option searches the given command as a regular expression in all the manuals and it returns the manual pages with the section number in which it is found.

Syntax:

$ man -k [COMMAND NAME]

Example:

$ man -k cd

Output:

The command ‘cd‘ is searched in all the manual pages by considering it as a regular expression.

6. -w option: This option returns the location in which the manual page of a given command is present.

Syntax:

$ man -w [COMMAND NAME]

Example:

$ man -w ls

Output:

The location of command ‘ls‘ is returned.

7. -I option: It considers the command as case sensitive.

Syntax:

$ man -I [COMMAND NAME]

Example:


$ man -I printf

Output:

The command ‘printf‘ is taken as case-sensitive i.e ‘printf‘ returns the manual pages but ‘Printf‘ gives error.



My Personal Notes arrow_drop_up

Appsecco | Web developer | IEEE | GeeksforGeeks Intern | Aspiring Cyber Security Specialist | Camcann Visit https//ashwingoelcom

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.