The Wayback Machine - https://web.archive.org/web/20240913164246/https://www.geeksforgeeks.org/man-command-in-linux-with-examples/
Open In App

How to Read Manual Pages in Linux | man Command

Last Updated : 10 Jun, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

The “man” command, short for manual, is a powerful tool in the Linux operating system that allows users to access detailed information about various commands, utilities, and system calls. The “man” command provides comprehensive documentation, helping users understand how to use and configure different elements of the Linux environment. This article will explore the “man” command in detail, covering its syntax, and options, and providing practical examples.

What is man in Linux Command?

The man command in Linux is used to display the manual pages for other commands and utilities. It provides detailed documentation about the usage, options, and functionality of commands, making it an essential tool for both beginners and experienced users. Each manual page includes sections such as NAME, SYNOPSIS, DESCRIPTION, OPTIONS, and EXAMPLES, which help users understand and effectively use the command.

Description

The man command is essentially the Linux manual reader. When you type man followed by a command name, it retrieves and displays the manual page for that command, offering comprehensive details on how to use it, including all available options and flags. This command is crucial for learning about the tools and commands available in the Linux operating system.

Syntax of the “man” Command

The basic syntax of the “man” command is as follows:

man [option] [command]

Here,

“option” refers to additional flags that modify the behavior of the “man” command,

“command” is the Linux command or utility for which you want to access the manual.

Man Command Options

The “man” command itself has options that enhance its functionality:

Option

Description

man [command]

Display the manual page for the specified command.

-f, –whatis

Display a concise one-line description of the command.

-k, –apropos

Search for commands related to a given keyword.

-a, –all

Display all matching manual pages for the specified command.

Spacebar

Move forward one page in the manual.

Enter

Move forward one line in the manual.

B

Move backward one page in the manual.

Q

Quit the manual viewer.

Accessing Manual Pages

  • To access the manual page for a specific command, simply type:
man [command]

For example: To view the manual for the “ls” command execute the following command:

man ls
  • This will display detailed information about the “ls” command, including its usage, options, and examples.

Once you’ve accessed a manual page, you can navigate through it using various commands. The common navigation keys include:

  • Spacebar: Move forward one page.
  • Enter: Move forward one line.
  • B: Move backward one page.
  • Q: Quit the manual viewer.

Sections in Manual Pages

Manual pages are organized into different sections, each serving a specific purpose. The primary sections include:

  • NAME: Provides the name and a brief description of the command.
  • SYNOPSIS: Describes the syntax of the command.
  • DESCRIPTION: Offers a detailed explanation of the command’s functionality.
  • OPTIONS: Lists the available command-line options and their descriptions.
  • EXAMPLES: Provides practical examples demonstrating command usage.
  • SEE ALSO: Suggests related commands or resources.

Types of sections in Man command Manuals

The man command manuals are divided into several sections, each providing specific types of information about the commands and features of the Linux operating system. Understanding these sections helps users navigate the extensive documentation efficiently. Every manual is divided into the following sections:

  1. Executable programs or shell commands: Commands that can be executed in the shell, like ls, cd, or grep.
  2. System calls: Functions provided by the kernel, such as open, read, and write.
  3. Library calls: Functions within program libraries, like those in the C standard library, such as printf and malloc.
  4. Games: Documentation for games available on the system.
  5. Special files: Usually found in /dev, these include device files like /dev/null and /dev/sda.
  6. File formats and conventions: Details on file formats and conventions, e.g., /etc/passwd.
  7. Miscellaneous: Including macro packages and conventions, e.g., groff(7).
  8. System administration commands: Commands typically used by the root user for system administration tasks, like iptables or mount.
  9. Kernel routines: Non-standard kernel routines used within the system.

Examples of Man Command section types with Detailing

The following are the examples of man command section types with detailing:

1. Section-num in man Command in Linux

  • In the man command manuals, sections are used to categorize different types of information. You can specify a section number to display only the relevant section of a manual.

Syntax

man [SECTION-NUM] [COMMAND NAME]

Example

man 2 intro

Output

This command displays the manual entry for the intro in section 2, which pertains to system calls. Specifying a section number ensures you get the precise information you need from the extensive Linux manual pages.

man 2 intro

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

2. -f option in man Command in Linux

  • 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

This command lists the sections where the ls command appears, indicating that ls is documented in section 1.

man -f ls

3. -a option in man Command in Linux

  • This option helps us to display all the available intro manual pages in succession.

Syntax

man -a [COMMAND NAME]

Example

man -a intro

Output

This command will show all intro manual pages one after the other, allowing you to cycle through them to find the specific information you need. This is useful for viewing multiple sections that a command might be documented in.

man -a intro

  • The following screenshot illustrate on the manual pages of intro of section 2:

manual intro page

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).

4. -k option in man Command in Linux

The -k option in the man command allows you to search for a command as a regular expression across all manual pages, returning a list of matching entries along with their section numbers.

Syntax

man -k [COMMAND NAME]

Example

man -k cd

Output

This command searches for the term “cd” in all manual pages and displays the relevant entries along with the sections where they are found. This is useful for finding related commands and topics within the manual pages.

man -k cd

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

5. -w option in man Command in Linux

  • The -w option in the man command returns the location of the manual page for a given command. This is useful for finding where the manual pages are stored on the system.

Syntax

man -w [COMMAND NAME]

Example

man -w ls

Output

In this example, the command man -w ls outputs the path to the manual page for the ls command, indicating where the documentation file is located on the system.

man -w ls

  • The location of command ‘ls‘ is returned.

6. -I option in man Command in Linux

The -I option in the man command makes the search case-sensitive, ensuring that the command name is considered with exact case.

Syntax

man -I [COMMAND NAME]

Example

The execution of following command helps in finding the manuals of printf command with case sensitiveness.

man -I printf

Output

This command searches for the manual pages of the printf command, treating the command name with case sensitivity. This is useful when differentiating between commands or sections that have similar names but different cases.

man -I printf

  • The following screenshot illustrates the manual of printf command with case -sensitive:

manual page for printf

  • The following looks for the manual pages for Printf command with case sensitive:

man -I printf

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

How to Search Manual Pages in Linux?

There are three main ways:

  1. Using the `man` command: This is the classic approach. Type `man` followed by the command name to find its manual page. For example, `man mkdir` will show you the manual page for the `mkdir` command.
  2. Using the `-k` option: Want to search for keywords across all manual pages? Use man -k followed by your keyword(s). For instance, `man -k permissions` will find pages mentioning “permissions“.
  3. Using the `apropos` command: Similar to `man -k`, but `apropos` also searches descriptions, not just names. Try `apropos networking` to find pages related to networking.

Alternative ways to read man pages

The following are the alternative ways to read man pages:

  • man2html: Converts man pages to HTML format, which can be easier to read on a graphical user interface (GUI).
  • tldr: Provides shorter, simplified versions of man pages.
  • whatis: Gives a very brief one-line summary of a command.
  • apropos: Searches the man pages for keywords and provides a list of commands and their brief descriptions.
  • info: Displays more detailed and hyperlinked documentation about commands and programs, often including more background information than man pages.

Conclusion

In this article we discussed the “man” command in Linux which is an essential tool for accessing detailed documentation on commands, utilities, and system calls. It provides a comprehensive guide with organized sections, including syntax, options, and examples. With options like -f, -k, and -a, users can quickly retrieve concise descriptions, search related commands, and access all matching manual pages.

Navigating through manual pages is simplified with common keys like Spacebar and Enter. The “man” command is not just a documentation tool; it is a valuable resource for users of all levels, contributing to a better understanding of Linux commands and enhancing command-line proficiency.

How to Read Manual Pages in Linux | man Command – FAQs

How to view the Manual for “cd” Command Using man Command?

The following command will display the manual page for the “cd” command, including information about its options, syntax, and examples.

man cd 

The following command will provide a list of commands related to the keyword “file,” helping users discover relevant utilities.

 man -k file

How to Display a One-Line Description of “ls” Using man Command?

The following command will present a brief one-line description of the “ls” command, useful for quick reference.

 man -f ls

I can’t find the man page for a specific command, what do I do?

There are a few possibilities:

  • The command might not have a man page. Some smaller or less common commands might lack documentation.
  • You might have misspelled the command name. Double-check your spelling and try again.
  • The man page might be located in a different section. You can use the -k option with man to search for keywords across all sections. For example, `man -k ls` will search for all man pages mentioning “ls”.



Previous Article
Next Article

Similar Reads

TLDR - Read man pages in simple format
If you also don't like to read the whole man page for simple commands and search the command options into the big man page, then the TLDR is for you. TLDR stands for the "Too Long; Didn’t Read“. TLDR is the same as a man page, but it provides a very sort description of tools and commands. TLDR provides the only required information about the comman
2 min read
How to View Colored Man Pages in Linux?
Man pages or simply manual pages are the documentation that is available with every command-line tool or application present to us in a Linux System. These types of documentation include topics from command-line tools, system calls, programs, and even abstract concepts. To read a man page simply type man <package> Man pages are usually monoto
3 min read
read command in Linux with Examples
read command in Linux system is used to read from a file descriptor. Basically, this command read up the total number of bytes from the specified file descriptor into the buffer. If the number or count is zero then this command may detect the errors. But on success, it returns the number of bytes read. Zero indicates the end of the file. If some er
1 min read
Ccat – Colorize Cat Command Output command in Linux with Examples
ccat is a command-line tool for Linux and OSX, which is similar to the cat command in Linux. But the difference between cat and ccat is that the ccat shows the content of the file with the syntax highlighted. Currently, ccat supports the following programming languages. JavaScriptJavaRubyPythonGoCJSONInstallation of Ccat First, we are going to see
2 min read
How to Display Command History in Linux | history Command
The command-line interface in Linux provides powerful tools for users, and mastering command history is essential for efficient navigation and retrieval of previously executed commands. The history command is a valuable utility that allows users to view and search through their command history. In this comprehensive guide, we will explore the vario
4 min read
Linux man page entries | different types
The man page(manual page) is a documentation manual of different commands available in unix or unix like operating systems. To check manual entry for any command use, man command_name In this article, I'm using command printf for my demonstrations. man printf Output: PRINTF(1) User Commands PRINTF(1) NAME printf - format and print data SYNOPSIS pri
4 min read
How to Read and Edit Systemd Logs using Journalctl in linux
In the realm of Linux system administration, managing logs is an indispensable task. System logs are crucial for understanding the health, performance, and troubleshooting of a system. Systemd, the init system widely adopted by modern Linux distributions, introduced a centralized logging system called the Journal. `journalctl` is the primary tool p
6 min read
Breacher - Tool To Find Admin Login Pages And EAR Vulnerabilities
Breacher is a free and open-source tool available on GitHub. Breacher is used as an information-gathering tool. This tool can be used to get information about our target(domain). We can target any domain using Breacher. The interactive console provides a number of helpful features, such as command completion and contextual help. This tool is writte
3 min read
select command in Linux with examples
select command in Linux is used to create a numbered menu from which a user can select an option. If the user enters a valid option then it executes the set of command written in select block and then ask again to enter a number, if a wrong option is entered it does nothing. If user enters nothing and simply press 'enter' the option menu gets print
1 min read
atrm command in Linux with examples
atrm command is used to remove the specified jobs. To remove a job, its job number is passed in the command. A user can only delete jobs that belong to him. Only superuser can delete any job even if that belongs to another user. Syntax: atrm [-V] job [job...] Options: -V : Used to print the version number atrm -V job : Job number of the job which i
1 min read
expand Command in LINUX with examples
Whenever you work with files in LINUX there can be a situation when you are stuck with a file containing many tabs and whatever you need to do with a file requires that file with no tabs but with spaces. In this situation, the task looks quite simple if you are dealing with a small file but what if the file you are dealing with is very big or you n
3 min read
rcp Command in Linux with examples
There comes a time while using LINUX when there is a need to copy some information stored in a file to another computer. This can be done simply using rcp command line utility . Obviously there exists some other methods to complete the above mentioned task which are more secure (like scp or rsync) but this command lets you do this in the simple way
4 min read
du Command in LINUX
While working on LINUX, there might come a situation when you want to transfer a set of files or the entire directory. In such a case, you might wanna know the disk space consumed by that particular directory or set of files. As you are dealing with LINUX, there exists a command line utility for this also which is du command that estimates and disp
9 min read
dmesg command in Linux for driver messages
dmesg command also called as "driver message" or "display message" is used to examine the kernel ring buffer and print the message buffer of kernel. The output of this command contains the messages produced by the device drivers. Usage of dmesg : When the computer boots up, there are lot of messages(log) generated during the system start-up. So you
5 min read
fmt command in Linux with examples
fmt command in LINUX actually works as a formatter for simplifying and optimizing text files. Formatting of text files can also be done manually, but it can be really time-consuming when it comes to large text files, this is where fmt comes to rescue. fmt re-formats each paragraph in the file specified, writing to standard output. Here's the syntax
4 min read
unexpand command in Linux with Examples
To convert the leading spaces and tabs into tabs, there exists a command line utility called unexpand command. The unexpand command by default convert each spaces into tabs writing the produced output to the standard output. Here's the syntax of unexpand command : Syntax : $unexpand [OPTION]... [FILE]... where, OPTION refers to the options compatib
2 min read
uniq command in Linux with examples
The linux uniq command is basically used to remove all repeated lines in a file. This command is used when a line is repeated multiple times and replace these multiple lines with one line. This command is designed to work on sorted files. Purpose : Remove repetitious lines from the sorted 'input-file' and send unique lines to the 'output-file'. If
2 min read
anacron command in linux with examples
anacron command is used to execute commands periodically with a frequency specified in days. Its main advantage over cron is that it can be used on a machine which is not running continuously. In cron if a machine is not running on time of a scheduled job then it will skip it, but anacron is a bit different as it first checks for timestamp of the j
3 min read
SED command in Linux | Set 2
We have discussed some of the SED command options in Sed Command in Linux/Unix with examples SED is used for finding, filtering, text substitution, replacement and text manipulations like insertion, deletion search, etc. It's a one of the powerful utilities offered by Linux/Unix systems. We can use sed with regular expressions. I hope atleast you h
8 min read
enable and disable command in Linux
Enables and disables are the built-in shell commands. enable command is used to start the printers or classes whereas the disable command is used to stop the printers or classes. Syntax For enable Command: enable [-a] [-dnps] [-f filename][name ...] Syntax For disable Command: disable [-c] [-W] [ -r [ reason ] ] printer Options: -a : List all built
1 min read
for command in Linux with Examples
for command in Linux is used to repeatedly execute a set of command for every element present in the list. Syntax: for NAME [in WORDS ... ] ; do COMMANDS; done Example: Options: help for : It displays help information.
1 min read
autoheader command in Linux with Examples
autoheader command in Linux is used to create a template file of C "#define" or any other template header for configure to use. If the user will give autoheader an argument, it reads the standard input instead of reading configure.ac and also writes the header file to the standard output. This command scans the configure.ac file and figures out whi
1 min read
expect command in Linux with Examples
expect command or scripting language works with scripts that expect user inputs. It automates the task by providing inputs. // We can install expect command using following if not installed // On Ubuntu $sudo apt install expect // On Redhat based systems $ yum install expect First we write a script that will be needing inputs from users and then we
2 min read
function command in Linux with examples
The function is a command in Linux that is used to create functions or methods. It is used to perform a specific task or a set of instructions. It allows users to create shortcuts for lengthy tasks making the command-line experience more efficient and convenient. The function can be created in the user's current shell session or saved in the shell
2 min read
fg command in Linux with examples
fg command in linux used to put a background job in foreground. Syntax: fg [job_spec] job_spec may be: %n : Refer to job number n. %str : Refer to a job which was started by a command beginning with str. %?str : Refer to a job which was started by a command containing str. %% or %+ : Refer to the current job. fg and bg will operate on this job if n
1 min read
bg command in Linux with Examples
bg command in linux is used to place foreground jobs in background. Syntax: bg [job_spec ...] job_spec may be: %n : Refer to job number n. %str : Refer to a job which was started by a command beginning with str. %?str : Refer to a job which was started by a command containing str. %% or %+ : Refer to the current job. fg and bg will operate on this
1 min read
Clear Command in Linux with Examples
clear is a standard Unix computer operating system command that is used to clear the terminal screen. This command first looks for a terminal type in the environment and after that, it figures out the terminfo database for how to clear the screen. And this command will ignore any command-line parameters that may be present. Also, the clear command
2 min read
Continue Command in Linux with examples
continue is a command which is used to skip the current iteration in for, while, and until loop. It is used in scripting languages and shell scripts to control the flow of executions. It takes one more parameter [N], if N is mentioned then it continues from the nth enclosing loop. The syntax for the `continue` command in Linuxcontinue or continue [
2 min read
hostid command in Linux with examples
hostid is a command in Linux that is used to display the Host's ID in hexadecimal format. It provides a quick and straightforward way to retrieve the host ID, allowing administrators to associate it with software licenses or perform system-specific operations. Syntax of `hostid` command in Linuxhostid [OPTION] Options provided by hostedhostid --hel
1 min read
Dirname Command in Linux with Examples
dirname is a command in Linux that is used to remove the trailing forward slashes "/" from the NAME and prints the remaining portion. If the argument NAME does not contain the forward slash "/" then it simply prints dot ".". In other words, we can say that the `dirname` command is a useful tool for extracting the directory portion from a given path
2 min read