FUNDAMENTALS A Complete Guide for Beginners
The Man Pages are among the vital features of Linux distributions. These are basically manual documents for the Linux commands. Most of the Linux commands come with a corresponding man page. In this article, you will get to know what is Man Page as well as its structure and sections in Linux.
What is Man Page in Linux?
The man page in Linux is the manual documentation of the Linux commands or programs. It is an abbreviation for “Manual Page”. In the Linux operating system, you can interact with the system by typing commands in the CLI ( Command Line Interface), where, a man page provides detailed instructions on the syntax and usage of these commands. Users can invoke the man page of a command by writing the man command itself. By default, it displays a conventionally structured manual of a command in the system’s terminal.
The “man” Command in Linux
The man command is used to view the man page of a particular command. It displays the list of options, arguments, command syntax, and applications. Moreover, the man command itself also comes with a specific syntax and several options. Below you will find some basic information about the man command.
The Linux “man” Command Syntax
The syntax of the man command in Linux is quite simple. It simply takes a command as input and shows information about that command.
man [man options] [[section] page ...] …
The Linux “man” Command Options
Multiple options are available for the man command in Linux. Some of the most used options are listed here. These options can be found on the generated man page of the man command by typing the following:
man man
The output of the man man command is as shown below.
The options found on this man page are as follows:
Options |
Description |
SECTION COMMAND | Shows the specific SECTION of a COMMAND. |
-k KEYWORD | Searches for the KEYWORD in the whole manual page and shows all the matches. |
-f KEYWORD | Looks for a short description of any KEYWORD or Command. |
-d, –default | Resets the man command behavior to default. |
-i, –ignore-case | Ignores case sensitivity of the command. |
-I, –match-case | Looks inside the man page with case sensitivity. |
-a, –all | Shows all manual pages that match the specific keyword or command. |
The Structure of a Man Page in Linux
The man page follows a conventional structure for the documentation of the commands. Because viewing command descriptions in a certain structure makes this man page convenient for the users. Below you will find the details on man page structure.
- NAME: Displays corresponding command name.
- SYNOPSIS: The syntax of the command.
- DESCRIPTION: A short description of the command.
- EXAMPLES: Provides examples of complex command applications.
- DIAGNOSTICS: Gives the possible error messages or status returned by the command.
- FILES: Lists the supplementary files needed to run the command.
- LIMITS: Describes the limitations of the command utility.
- PORTABILITY: Provides a list of other compatible systems for the utility.
- SEE ALSO: Gives a list of related man pages.
- HISTORY WARNING (or Bugs): Provides warnings and advice for users.
- NOTES: Other important information.
The Sections of a Man Page in Linux
In Linux, man pages have a total of 9 sections to make it easier to find useful information. Each of these sections describes a specific topic. The sections are described as follows:
1. User commands: Describes user commands and tools such as shells, compilers, editors, etc.
2. System calls: Describes system calls which is an entry point into the kernel and similar to invoking a library function.
3. Library functions: Explains all library functions except for the ones included in system calls.
4. Special files: Contains man pages for special files such as device and configuration files etc.
5. File formats and conventions: Provides the file formats, conventions and protocols used by the system.
6. Games: Describes all the installed games and fun programs.
7. Miscellaneous: Gives an overview of various topics including standards, layout, conventions, protocol, etc.
8. System administration commands: Includes man pages for commands that are used by system administrators.
9. Kernel routines: Contains man pages for Kernel routines that are typically accessed by the kernel developers.
How to View a Man Page in Linux
The main objective of the man page is to provide user-friendly command documentation. Therefore, the Linux distribution offers multiple ways to view the available man pages and extract necessary information. Furthermore, users can view a command-specific man page as well as filter the pages depending on the available sections. In this section, I have described multiple ways to view man pages in Linux.
A. Viewing the Man Page of a Specific Command
Finding a specific man page is the main function of the man command. Therefore, you must follow the given syntax to get a command-specific man page.
man COMMAND
In this example, I will show you the man page of the ls command. You can follow the steps given below to do the same:
-
Open the Terminal.
-
Type the following command and press ENTER:
man ls
Note: To get out of the man page, you need to press the Q key from the keyboard.
In the image below, you can see that the man page for the ls command is shown.
B. Viewing a Particular Section of a Command from the Man Page
You can see the particular sections from the man page. To do so you must follow the general syntax below:
man SECTION_NUM COMMAND
man COMMAND.SECTION_NUM
Not all commands have different sections. The man command itself has two sections: section 1 and section 7. In this example, I will filter section 7 of the man command. To get the same results, follow the steps below:
-
Launch the Ubuntu Terminal.
-
Type either of the following commands in the command line and press ENTER:
man 7 man
Or,
man man.7
In the following image, you can see that I have displayed section 7 of the man page.
C. Displaying All the Man Pages of Different Sections
Some commands have many sections and you may want to view all of these sections one after another. In that case, you need to use the -a option to view all the different man pages of the particular command. However, the general syntax is as follows:
man -a COMMAND
In this example, I will list all the different sections of the intro command. You can do the same by following the steps mentioned below:
-
Go to the ubuntu Terminal.
-
Type either of the following commands in the command line:
man -a intro
- Press ENTER to get inside the man page of the first section of the intro command.
-
Hit Q to quit this section.
-
Now, press CTRL+D to list the next section, or, press CTRL+C to quit the command.
-
Again, press the ENTER key to get inside the recently listed section.
In the 1st image, you can see that the command by default shows section 1 of the intro command.Moreover, in this second image, you can see that a list of all available sections is listed for the command.
Conclusion
In this article, I have described the prime objectives and functions of the Man Page in Linux. It is one of the features that make Linux distributions user-friendly. You will be able to learn about useful commands solely from the Man Page. Here, I have also demonstrated the structure and sections of the page for your better understanding. I hope knowing this Linux feature aids your journey with the command line and makes you a power user.
People Also Ask
What does the man page do in Linux?
Man pages are simply the called manual pages that provide users with an understanding of how to use the commands in Linux. A default addition to the Linux system, the man page explains how a command works by offering detailed information and documentation for commands. The man pages are accessed via the terminal using the man
command followed by the command name.
How do I access the man page?
To access the man page, use the man
command and specify the command or function name you wish to learn. For instance, the man ls
command returns the man page for the ls
command to the terminal, displaying detailed information on command usage instructions, options, descriptions, etc.
Can I display the man page from a specific section?
Absolutely. To display the man page from a specific section, run the command man with the full syntax man <section number> <command name>. For example, to open the man page of the Linux sleep
command from section 3, run the command man 3 sleep
. The output shows only the page from section 3 of the manual.
How do I navigate a man page in Linux?
To navigate a man page, you can use the arrow keys, Page Up/Down, or spacebar to scroll through a man page. To exit, press q. For specific searches, type / followed by the search term and press Enter to find instances within the man page.
How many sections are there in a man page in Linux?
There are 9 different sections in a man page:
- User commands.
- System calls.
- Library functions.
- Special files.
- File format and conventions.
- Games.
- Miscellaneous.
- System administration commands.
- Kernel routines.
What if I can’t find the man page for the specified command?
If you can’t find the man page (manual page) for a specific command, then check for any typos or alternative names of the command or keyword you are searching for. Or, you can run the man -k <keyword> command in the terminal to search for man pages again containing the specific command or keyword.
Can I access the man page for the man command?
Yes. Run the command man man
in the terminal to display the manual pages of the Linux man command providing detailed information on syntax, options, and functionalities.
Similar Readings