Skip to content

Click on each book below to review & buy on Amazon.

As an Amazon Associate, I earn from qualifying purchases.


RHCSA - Understand and Use Essential Tools: Locate, Read & Use System Documentation Including man, info & Files in /usr/share/doc

Man Pages

Man pages, short for "manual pages", are a comprehensive documentation system in Linux that provide detailed information on various commands, utilities, and system functions. They serve as a valuable resource for users to understand and utilize the vast array of tools available in the Linux ecosystem. Each man page offers a concise yet comprehensive description, including command syntax, available options, examples, and additional details. These pages are organized into sections based on the type of information they provide, allowing users to quickly access the relevant documentation they need.

To access the manual pages you use the man command against an item or program, where an item or program fits into a category in the upcoming Man Page Sections.

Man Page Synopsis

When you open a man page it can sometime be confusing to understand how you should use certain options and flags for a command. The below table will help understand the syntax:

Syntax Description
[] Optional parameter
| Choice between options
... Variable number of the preceding options or arguments
- Denotes an option or flag
-- Denotes a long option or flag

The following are some example command synopsis:

kill [options] <pid> [...]
ls [OPTION]... [FILE]...
grep [OPTION...] PATTERNS [FILE...]
grep [OPTION...] -e PATTERNS ... [FILE...]
grep [OPTION...] -f PATTERN_FILE ... [FILE...]

Man Page Navigation

Once inside a man page you can navigate using certain keys or search for text:

Key Function
h or ? Display the help or information on how to navigate the man page
SPACEBAR or f Scroll forward by one window
b Scroll backward by one window
j or DOWN ARROW Scroll down by one line
k or UP ARROW Scroll up by one line
/search_term Search forward for a specific search_term
n Move to the next occurrence of the search term
N Move to the previous occurrence of the search term
q Quit and exit the man page viewer

Accessing the manual page for the ls command & practicing navigation and searching:

man ls

Now the man page for ls is open, perform the following:

  1. Press Space or F to page down
  2. Press B to page up
  3. Press Down or J a few times to move down a few lines
  4. Press Up or K a few times to move up a few lines
  5. Type /directory and press Enter to search for the text directory
  6. Press N a few times to search through every occurrence of the text directory

Man Page Sections

The following table details the different sections that man pages may fall into:

Section Number Section Title Description
1 User commands Commands that can be executed by the user from within a shell.
2 System calls Functions which wrap operations performed by the kernel.
3 Library calls All library functions excluding the system call wrappers.
4 Special files (devices) Files found in /dev which allow access to devices through the kernel.
5 File formats and configuration files Describes various human-readable file formats and configuration files.
6 Games Games and funny little programs available on the system.
7 Overview, conventions, and miscellaneous Overviews or descriptions of various topics, conventions and protocols, character set standards, the standard filesystem layout, and miscellaneous other things.
8 System management commands Commands like mount(8), many of which only root can execute.

By default, when using the man command to access manual pages, it will display the man page that is first found in section order. However you can specify which section you would like by using either of the following, where n is to be replaced with a section number:

  • man n item
  • man item.n
  • man 'item(n)'

Access the manual page for the passwd configuration file:

man 5 passwd

The top line of the file shows PASSWD(5), confirming the section we specified has correctly displayed.

PASSWD(5)                 Linux Programmer's Manual                 PASSWD(5)

Access the manual page for the passwd user command:

man passwd

The top line of the file shows PASSWD(1), confirming that man did find the first section that matched, and did not, for example, display PASSWD(5) for the configuration file.

PASSWD(1)                       User utilities                       PASSWD(1)

Finding a man Page

You may know what you want to do but can not remember the command you need to do it. This is where searching the man pages comes in handy, which can be achieved by using either man -k search_string or apropos search_string.

You are aware that you can search within compressed files, but have only ever used the grep command for normal files. You search the man pages for any other grep commands that could be of use:

man -k grep

A few different utilities are returned that match your grep search, including:

  • bzgrep: Search bzip2 compressed files for a regular expression.
  • xzgrep: Search xz, lzma, gzip, bzip or lzop compressed files for a regular expression.
  • zgrep: Search compressed or gzip files for a regular expression.

Confirm apropos also performs the same search:

apropos grep

Updating Manual Database

To update the manual database that stores the manual page index caches, you use the mandb command as root or using sudo. This is useful to run manually if you suspect the database is missing entries or is out of date.

Updating the manual database:

sudo mandb

You will see the final few lines of output similar to:

79 man subdirectories contained newer manual pages.
785 manual pages were added.
0 stray cats were added.
20 old database entries were purged.

Rather than relying on running mandb manually, you can install the man-db-cron package which will ensure the manual database gets updated daily.

Info Pages

Info pages are an alternative that provides detailed information on commands, utilities, and topics. They are similar to man pages but offer a more structured and interconnected format. Info pages consist of nodes that contain information about specific topics and are linked together to form a hierarchical structure. This allows users to navigate between related topics easily and access detailed information on various commands, concepts, and procedures.

To access the info pages, you use the info command followed by the name of the item or topic you want to explore. The info pages are organized into a tree-like structure, with the main menu serving as the entry point. From there, you can navigate through different nodes, view subtopics, and access detailed documentation.

Info Page Navigation

Once inside an info page, you can navigate using certain keys and commands:

Key Function
h Display the help or information on how to navigate the info page.
n Move to the next node or scroll forward.
p Move to the previous node or scroll backward.
u Move up to the parent node.
TAB Move to the next hyperlink or cross-reference.
RETURN Follow the selected hyperlink or cross-reference.
q Quit and exit the info page viewer.

Accessing the info page for the awk command & practicing navigation:

info awk

Now the info page for awk is open, perform the following:

  1. Press Tab twice to highlight the * Options hyperlink
  2. Press Enter to follow the link
  3. Press N to move to the next page Other Arguments
  4. Press P to return to the previous page Command-Line Options
  5. Press U to move up to the parent node
  6. Press Q to quit

Documentation in /usr/share/doc

The directory /usr/share/doc is a commonly used for storing documentation files associated with various software packages installed on the system. It serves as a central repository for documentation that provides additional information, instructions, and usage guidelines for the software.

Within /usr/share/doc, you will typically find subdirectories organized by package names or categories, containing relevant documentation files. These files can include manuals, README files, changelogs, licenses, examples, and other documentation resources. The purpose of this directory is to make it easier for users and administrators to access and consult the documentation related to the software installed on their system.

--help Command Option

It is worth mentioning the --help command option as it is available for most commands. It provides a short summary of the options and arguments the command takes. Even if a command does not have the --help option available, it will be kind enough to give an error and then provide the help summary anyway.

Exercise: Use the --help option to view command options:

View the --help output for the cat command:

cat --help

The output of will resemble:

Usage: cat [OPTION]... [FILE]...
Concatenate FILE(s) to standard output.

With no FILE, or when FILE is -, read standard input.

  -A, --show-all           equivalent to -vET
  -b, --number-nonblank    number nonempty output lines, overrides -n
  -e                       equivalent to -vE
  -E, --show-ends          display $ at end of each line
  -n, --number             number all output lines
  -s, --squeeze-blank      suppress repeated empty output lines
  -t                       equivalent to -vT
  -T, --show-tabs          display TAB characters as ^I
  -u                       (ignored)
  -v, --show-nonprinting   use ^ and M- notation, except for LFD and TAB
      --help     display this help and exit
      --version  output version information and exit

Examples:
  cat f - g  Output f's contents, then standard input, then g's contents.
  cat        Copy standard input to standard output.

View the --help output for the clear command:

Notice how the output states that -- is an invalid option and proceeds to print what we need anyway.

clear: invalid option -- '-'
Usage: clear [options]

Options:
  -T TERM     use this instead of $TERM
  -V          print curses-version
  -x          do not try to clear scrollback

Support DTV Linux

Click on each book below to review & buy on Amazon. As an Amazon Associate, I earn from qualifying purchases.

NordVPN ®: Elevate your online privacy and security. Grab our Special Offer to safeguard your data on public Wi-Fi and secure your devices. I may earn a commission on purchases made through this link.