Introduction to Linux Manual Pages
In Linux, the manual pages often abbreviated as man pages and is a system’s manual pager and serve as documentation for all kind of computer programs’ purpose in Unix or Unix-like operating systems. In this documentation, there are various topics covered like library and system calls, computer programs, conventions, and standards that are generally formal and some abstract concepts. There is a specific command which invokes the man page. These pages can be put analogous to the online documents that are quite popular today but not exactly the same because documentation on web pages is out of band documentation and would need some internet source to get to read the documentation, whereas the man page comes with the operating system distribution itself.
Now that we know that manual pages are used for displaying user manuals of any command one would like to view it for, it becomes imperative to understand the syntax first, the various options available so that it becomes easier for one to understand the flow and usage of man pages. The syntax is as follows:
man [OPTION] [COMMAND NAME]
Over here, the main keyword is the man, which essentially helps in invoking the command for manual pages. Next, the [OPTION] is a placeholder to provide any options that will denote a particular utility. Finally, [COMMAND NAME] refers to the command for which we want to view the user manual.
As the next set of syntax, this syntax is used when one needs to look at a particular section number for a command. Below is the syntax:
man [SECTION-NUM] [COMMAND NAME]
Again, over here, the main keyword is the man who invokes the command for manual pages. Next, the [SECTION-NUM] is a placeholder to provide the section number one needs to refer to for command, and finally [COMMAND NAME] refers to the command for which we want to view the user manual for.
In the next section (How manual pages work), we would understand the different options available in man pages in; over some sections later; we would look at examples from the different sets of examples discussed there.
How manual pages work in Linux?
Manual pages comprise of different sections, about which we will learn in detail in this article but let us list them down here for summarization and prepping up for the next few paragraphs. Manual pages have a detailed view of the command in place and include:
- Exit status
- Return values
- See Also
Now let us look at a few options which are in general used widely when one refers to manual pages. At first, we have a scenario when there is no OPTION given, which will essentially display the entire content from the command’s manual.
man [COMMAND NAME]
This is useful for someone who wants to go through each and every detail of the command and has no specific requirement of a section or utility of the command. This portion serves as documentation for the command and is also very useful for beginners to get the hang of the entire usability of the command.
Second, we have a reference with the section number. The syntax and way of working for the command are as below:
man [SECTION-NUM] [COMMAND NAME]
The manual page is usually divided into multiple sections. This is useful when one needs to refer to a specific section number for the utility of the command. Often this option is used by oneself when one is confident about the command to be used but needs to confirm the particular utility in terms of syntax or feasibility of the same.
Third, we have the -f option; there are times when one may not remember the section number of a particular utility of the command. This option will help list down the essential headlines of a particular section and make concise information of the sections present in the command.
man -f [COMMAND NAME]
Fourth, we have-a an option that will help display the intro manual pages that are available in succession. Thus, one would be able to skim through each of the sections in succession and choose to either read it by pressing Enter or skip it by pressing Ctrl + D or exit altogether from the succession points by pressing Ctrl + C.
man -a [COMMAND NAME]
Fifth, we have a -k option that enables the user to use regex to find all the commands that match the regex. If one vaguely remembers the command name, but not exactly, using this option user can get to know the command which has the corresponding utility. For example, if one knows that print is a regular expression present, one can use the same and get the list of all those that have print as a sub-word print. Then, out of the list, one can choose the desired command.
man -k [COMMAND NAME]
Sixth, we have the option of -w, which returns the manual page’s location in the UNIX environment.
man -w [COMMAND NAME]
Last but not the least, there is an option of -I, which makes a command case sensitive. This essentially means that printf and Printf are 2 separate commands and can’t be treated as the same.
This section will go through all the options we have discussed earlier through a particular example.
man 2 printf
man 2 intro
man -f printf
man -a printf
man -k printf
man -w printf
man -I printf
man -I Printf
Here the command “printf” is taken as being case-sensitive, and hence the usage of Printf leads to the return of error.
In this article, we have taken you through a ride through all the options that are possible with the usage of manual pages in Linux and serve a wide variety of audience using the manual pages starting from someone who wants to learn about commands from scratch to the one who needs to refer the manual pages to confirm a particular utility!
This is a guide to Linux Manual Pages. Here we discuss How manual pages work in Linux and Examples along with the syntax and outputs. You may also have a look at the following articles to learn more –