Getting help from linux man pages

Table of contents

Linux ships with a high-quality documentation for almost all parts of the operating system and installed programs. With all that helpful information at your finger tips, let's learn how to use it effectively

What are man pages?

The word man is simply short for manual. It is the command you use to read manual entries in linux. Manual pages may be split into multiple sections, with sections commonly containing the following information:

  1. User Commands: This section covers commands available for general users.
  2. System Calls: Describes the functions provided by the kernel to interact with the system.
  3. C Library Functions: Covers functions available in the C standard library.
  4. Devices and Special Files: Documents device drivers and special file formats.
  5. File Formats and Conventions: Provides details about file formats and configuration files.
  6. Games: Documents various games available on the system.
  7. Miscellaneous: Contains overviews, conventions, and other general information.
  8. System Administration: Covers commands used by system administrators.
  9. Kernel Routines: Describes kernel internals and low-level programming interface

For more detailed information about man pages and section, man ships with the intro page, which you can access with man intro. The intro page has 8 sections, each describing what the section would commonly be used for. You can open a specific section by providing the section number, e.g. man 4 intro would display section 4 of the intro page. If you see references like intro(3) in man files, they refer to specific sections of pages, intro(3) for example can be viewed by running man 3 intro.

Finding the man pages you need

A man page may have any of the sections described above, for example the man entry for pipe only contains section 7, because there is nothing from the other section categories to be found in that documentation. To list all sections available for a man page, use the -f flag. To list all sections for the intro page for example:

man -f intro

Would print

intro (1)           - introduction to user commands
intro (2)           - introduction to system calls
intro (3)           - introduction to library functions
intro (4)           - introduction to special files
intro (5)           - introduction to file formats and filesystems
intro (6)           - introduction to games
intro (7)           - introduction to overview and miscellany section
intro (8)           - introduction to administration and privileged commands

The output contains a list of all sections within that man page entry and a short description of it's contents.

But how do you find the page containing the information you need? You search for it of course! The search for entries containing a specific keyword, use -k

man -k intro

If you need more complex search capabilities, use regular expressions:

man -k --regex '.*intro.*game.*'

There are more specific search options like wildcard or case-sensitive matching, for a full list check man --help.

About bash builtins

An issue people commonly run into is searching for man pages for commands like fg or alias. Surprisingly, there are no maual entries for them. That's because they are not actually installed programs, but builtin bash commands. The bash shell has it's own mechanism for reading documentation: The help command. Run it without arguments to get a list of all supported topics:

help

This prints a list of all the things bash could print help output for.To get the documentation for the fg command, for example, simply run

help fg

And that's it. Now you should be armed with all the knowledge you need to find whatever documentation you were looking for - or at least for the commands installed on your system.

More articles

Javascript arrow functions explained

Making modern javascript code more compact

Getting more out of javascript console messages

Going beyond console.log to find more gems in the console package

Handling javascript exceptions

Mistakes happen, here is how you deal with them

The downsides of source-available software licenses

And how it differs from real open-source licenses

Configure linux debian to boot into a fullscreen application

Running kiosk-mode applications with confidence

How to use ansible with vagrant environments

Painlessly connect vagrant infrastructure and ansible playbooks