Man command in Linux with Examples

Posted in

Man command in Linux with Examples
vinaykhatri

Vinay Khatri
Last updated on November 14, 2024

    It is essential to understand all of the utilities and commands that you use while working with Linux-based operating systems. Furthermore, instead of looking for it elsewhere, you need a tool that provides you with the whole explanation of the command at once. You may use the man command in Linux to assist you out here. It is used to obtain manuals or documentation for the supplied command on your terminal.

    In this article, we will look at the man command and how you may use it to receive a description of a wide range of Linux tools and commands.

    man command in Linux

    This is a very helpful command in Linux-based Operating Systems that serves as the manual or documentation for various Linux utilities and commands. This is particularly helpful for beginners as they get a complete description of a particular command right in their terminal. This command provides information about options, arguments, authors, return values, examples, versions, etc., for the specified command.

    The syntax for the man command is:

    $ man [option] [section] [command]

    Sections of the man command in Linux:

    The manuals for the utilities and commands are divided into sections. If we do not provide the section number, it will look into every section and return the first one that matches the input. We can specify the section number in the command for fast searching. There are 9 sections available in the manuals.

    • General commands: Contains all the system commands that are generally used by the users.
    • System calls: This section contains the manual for various system calls.

    The operating system serves as a bridge between the user and the hardware. This implies that if any apps wish to interface with the hardware, they must do so through the operating system because applications cannot directly access hardware. But how does communication between apps and the operating system take place? This is where the system call comes in.

    System calls act as a channel between user programs and the operating system. In most circumstances, a user application does not directly invoke system calls. They make use of the application programming interface (API), which in turn makes calls to the system call.

    The system call handler validates the syscall number stored in a register before executing the system call associated with the syscall number. System calls thoroughly validate all of their parameters (stored in registers) to verify that they are valid and lawful.

    • Library Functions: This includes the functions present in various libraries in the Operating System.
    • Special files: These files are found in the directory /dev
    • Games
    • File formats/extensions
    • Administration commands for admin
    • Kernel Routines: Information regarding the working of kernel
    • Miscellaneous: Contains manual for different macro packages, boot parameters, etc.

    Examples of man command in Linux

    1. Search the manual pages

    To look for all the manual pages which match the given command name, use the below syntax.

    $ man -f [command]

    Example:

    2. Search manual pages from specified sections

    $ man [section] [command]

    Example:

    3. Display the manual pages in the browsers

    You will need a groff package to accomplish this task. Install this package and type the following sequence of commands:

    $ export BROWSER=brave

    $ man -H brave [command]

    We used “Brave” browser in our case. However, the same command works for Firefox, Chrome and other browsers as well. Example:

    4. Get quick insight of a command

    The below option allows us to get a brief description of a particular command.

    $ man -f [command]

    Example:

    5. Get all the manuals

    To get all the available manuals for a command, use the below syntax:

    $ man -a [command]

    Example:

    Exit status of man command in Linux

    0: Program execution was successful. 1: Error in use, syntax, or configuration file. 2: Error in operation. 3: A non-zero exit status was reported by a child process. 16: At least one of the pages or files was not found.

    Conclusion

    In this article, we discussed the man command in Linux that gives you insights on various commands and utilities available in Linux. We can search for manuals through patterns and even view our manuals on browsers.

    People are also reading:

    Leave a Comment on this Post

    0 Comments