man command in Linux with Examples

18 Feb, 2021
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]...

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.Linux Tutorials | Getting Help and Escaping | GeeksforGeeks - YouTubeGeeksforGeeks529K subscribersLinux Tutorials | Getting Help and Escaping | GeeksforGeeksWatch laterShareCopy link8/36InfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:000:00 / 3:39•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=USMVhdydb4Y" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>
linux-command
Linux-misc-commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
tar command in Linux with examples
curl command in Linux with Examples
Tail command in Linux with examples
Conditional Statements | Shell Script
Docker - COPY Instruction
scp command in Linux with Examples
UDP Server-Client implementation in C
echo command in Linux with Examples
Cat command in Linux with examples
touch command in Linux with Examples