How to Easily Read a Linux Man Page

linx-man-page-featured

One of the most important skills you can learn as a Linux user is how to use a manual page, or “man page.”

This article will introduce you to those simple documents. You’ll learn how to open man pages and identify the contents inside, which will include special markings such as bold and underlined text alongside indicators such as ellipses (…) and brackets ([ ]).

Man pages are fairly easy to tackle, and your time is valuable, so let’s not waste another minute.

Also read: 5 Useful Terminal Tools to Better Manage Processes in Linux

Opening Man Pages

In whichever terminal you have on hand, type

man <page name>

to open a man page. If you want to open the page for xterm, a terminal probably on your system, type man xterm.

Man pages are sorted into sections. Sometimes you will find them listed with their section number, like “tty(4).” The section number here refers to the tty controlling terminal under the “Special files (devices)” section, which is part of the standard sections of man pages listed in the link in this paragraph.

Any time you see a listing like “tty(4),” you can reach that section by typing

man <section number> <page name>

The syntax man 4 tty will reach the page reference here.

Finding a Specific Page

If you ever want to see if a man page exists, try

whatis <keyword>

like whatis xterm.

Suppose you don’t know what page you need, but you know you want to read about terminals. You can search for a keyword by first refreshing your manual page cache with the command

mandb

Then search with

man -k <keyword>

The syntax man -k terminal is appropriate in this situation.

You can pipe long output into the text reader less by using

man -k terminal | less

That will make it easier to scroll and search for items.

Man Page Syntax

Speaking of text readers, you will probably find less‘s younger cousin, known as more, on your system. Bring up its man page with

man more

It should look like the following image.

Man page for 'more'

The reason more‘s man page works well as an example is because of the syntax shown in its Synopsis section. It reads “more [options] file…”

While that may not look complex, the variations in text style and form are all important to that line.

Bold Text

Any text in bold means that you should type it exactly as shown. When using the more utility, you will need to type the word “more” at the beginning of every command.

Brackets

Text shown in brackets is optional. In more’s case, you can use options like -f to count logical lines or -c to paint lines instead of scrolling them. The beginning of a more command could then look like

more -f

or

more -f -c

Since those parameters are optional, you can omit them entirely.

Underlined or Italicized Text

Depending on your terminal’s capabilities, you will likely see underlined and italicized text in certain places. Sometimes such text may also be a different color. In any case, this type of text means you need to replace it with an appropriate argument.

In this example with more, you must replace “file” with a file name. more -c file.txt makes sense here.

Ellipses

An ellipsis shown after any argument — file... – or expression – [options]... – means that argument or expression is repeatable.

What you get with more in file... means that something like

more -f text.txt anothertext.txt

is allowed. In this case more will read “text.txt,” print it to screen, allow you to scroll if necessary, and then take action on “anothertext.txt.”

Or

One other type of indicator you’ll see in man pages is the “|.” This symbol means “or,” and in a man page it shows you that, for instance, two options are not allowed together at once.

The more example used above doesn’t list any parameters as being exclusive, so there isn’t a relevant example to show for that utility. If you read a handful of other man pages, however, you will come across something like -a|-b, and that means you can use only -a or -b in a command.

Sections of a Man Page

You will also see various sections in man pages that repeat time and time again. Typically, you will see “NAME,” “SYNOPSIS,” “DESCRIPTION,” “EXAMPLES,” and “SEE ALSO” sections, all listed in capital letters for clarity. The “OPTIONS” and “COMMANDS” sections will often be present as well.

Most of the sections are self-explanatory in nature. You can typically start from the top of any man page and get a brief overview of its contents with the Name, Synopsis, and Description sections. Afterward, you can peruse its options and examples to get a look at common usage.

Terminals often use the less utility to read man pages, so you should be able to search for any phrase with /.

Conclusion

While man pages might not be fancy, they hold a wealth of information. Now that you’re primed with the basic syntax found in most man pages, you can easily make use of one the next time you’re stuck when using a utility.

Also, don’t forget that man man is your friend and will cover all the details not discussed here.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Casey Houser

I have worked as a professional writer since 2011. I like to compose my articles in Vim, which I also use for hobbyist C and Ruby projects. When I'm not in front of a text editor, I run, bike, and play tennis until I'm too tired to move.