Chat Zalo Chat Messenger Phone Number Đăng nhập
Man Command in Linux {With Examples} | phoenixNAP KB

Man Command in Linux {With Examples} | phoenixNAP KB

Introduction

The man command is a built-in manual for using Linux commands. Allows users to view the reference manuals of a command or utility executed in the terminal. The man page (short for manual page) includes a description of the command, applicable options, flags, examples, and other informational sections.

In this tutorial, you will learn how to use the man command on Linux.

prerequisites

A

  • machine running
  • Linux Command

  • Line Access
  • An account with Linux man root privileges

Command syntax

The

basic syntax of

the man command is: man [option]

[command name] option: The

  • search result
  • .

  • Section number: The section in which the man page is searched.
  • Command name : The name of the command page you want to view.

By default, man searches all available sections of the manual and displays the first match (even if the page exists in multiple sections). Providing a section number instructs the man command to search a specific section.

There are nine sections of the manual:

1. General commands: Commands used in the terminal.

2. System calls: Functions provided by the kernel.

3. Library functions: Functions in program libraries.

4. Special files: Usually devices found in /dev and related drivers.

5. File formats

and conventions: file formats like etc/passwd

.

6. games: Descriptions of commands that display database appointments.

7. Miscellaneous: Various descriptions, including macro and convention packages, boot parameters, and others.

8. System administration commands: Commands mostly reserved for root.

9. Kernel routines: Information about kernel internal operations.

How to use man in

Linux

In the terminal window, type man followed by the name of the Linux command you want to view

.

The output is long. Use the mouse scroll wheel, up and down arrow keys, or PgDn and PgUp keys to navigate through the mouse.

After running the man command, press H to see the help section and a table of possible keystrokes to navigate the output.

To exit, press Q.

The command output displays the manual page headers available for the specified command.

The

list of possible headers includes

: Name: The name of the command.

  • Synopsis: Syntax
  • of the command.

  • Configuration: Configuration details for a device
  • . Description: Description of the command.

  • Examples: Several examples that demonstrate the use of the command.
  • Defaults: The default features of the command and how they can be overridden.
  • Options: A list of options and flags that the command accepts.
  • Output State: A list of possible output state values for the command.
  • Environment: List and description of environment variables that affect the command.
  • Files: A list of files used by the command.
  • See also: Commands related to the topic described.
  • Authors: The people who wrote or maintain the command.
  • History: Command development history.
  • Notes: Multiple notes, including required permissions, dependencies, etc.
  • Errors: Any known issues in this version of the program.

Find

man pages The -f option displays all man pages that match the specified command name

and indicates the sections in which the given command is present

.

Use the following syntax:

man -f [command name]

The result is a list of results that match your search criteria. With multiple matches, the number next to the search result indicates the section.

Show man pages of specific

sections

To display the page of a specific section of a manual,

use the syntax

: man

[command name]

For example:

man 3 sleep

The result displays only the page of section 3 of the manual

.

Display man pages in a browser

Man pages are long and sometimes difficult to navigate to find the information you need. The man command allows users to display man pages in a browser to easily find information.

To do this, follow these steps:

1. Make sure that the groff package is installed. Run:

sudo apt-get install groff

2. Before calling the man command, select a default browser. Run:

export BROWSER=firefox

To use a different browser, replace firefox with google-chrome, chromium-browser or any other browser

. 3. Use the -H option to

read the man page in a browser of your choice: man

-Hfirefox vmstat The –

H option instructs groff to produce HTML output and displays that output in a browser

. Show man pages and print short descriptions The -f option allows users to search for

man pages and print short descriptions

of the specified command in the terminal. The syntax is:

man -f [command name] Show all man pages The -a attribute

allows users to display all available manual getting started pages contained in each section

, one at a time.

man

-a [command name]

Exit between successive screens or skip through them using Ctrl + C or Ctrl + D, respectively

.

Search considering the input

as a regular expression

The -k allows users to search short command descriptions and manual page names for a keyword specified as a regular expression. The output shows the available matches.

The

syntax is:

man -k [command name] Show location of

man pages

The -w attribute displays the location of the manual page for the specified command. Adding the -a option prints the locations of all files that match the keyword.

The syntax is:

man -w [command name]

In this example, we use the -a option to view the locations of all associated man pages

.

In addition, using the -W option displays the location of the preformatted cat file. With the -a option, prints the locations of all preformatted cat files that match the keyword.

Enable case-sensitivity To search for

case-sensitive

manual pages

, use the -I option. The syntax is:

man -I [command name]

The man’s default setting is to ignore case when searching for manual pages. To revert to the default settings and ignore case studies, use the -i option.

Conclusion

Now you know how to use the man command on Linux. Use the command to view user manuals for Linux commands, search for a specific keyword, or view all manual entries.

To learn how you can search all manual pages using details known as a search term, be sure to read our article about the Linux command.

For more uses, check out our article and find out how man command can review the full Expect manual.

Contact US