Command Line · Lesson 16 of 19

man

0 / 5 checkpoints answered

Full screen ↗

Many Linux commands, interfaces, configuration files, and administrative tools have installed reference documentation called manual pages, or man pages. The man command finds and displays those pages.

Opening a Manual Page

Pass a topic name to man. For example, open the page for ls with:

$ man ls

Manual pages commonly include a synopsis, description, options, related files, and cross-references, although the exact sections vary.

CheckWhich command opens the installed manual page for ls?

Navigating and Searching a Page

On many systems, man displays pages through a pager such as less. While a page is open, you can scroll with arrow or page keys and use these controls:

Inside a man page:

  • Type /pattern and press Enter to search forward.
  • Press n to repeat the search in the same direction.
  • Press N to repeat it in the opposite direction.
  • Press q to quit.

The pager can differ by system or environment, so its exact keys are not guaranteed everywhere. The controls above apply to the common less setup.

CheckWith a man page open in less, what starts a forward search for --recursive?

CheckWith a man page open in the usual pager, which key returns to the shell?

Selecting a Manual Section

The manual is organized into numbered sections. Common sections include:

  • 1: User commands.
  • 2: System calls.
  • 3: Library functions.
  • 5: File formats.
  • 8: System administration commands.

The same topic can appear in more than one section. Put the section before the topic to select one explicitly:

$ man 5 passwd
$ man 1 passwd

The first command opens the passwd file-format page from section 5. The second opens the user command page from section 1. References such as passwd(5) use the same topic(section) notation.

CheckWhich command opens the section 5 page that documents the passwd file format?

When a Page Is Missing

Not every command name has a separately installed manual page. If man reports that no entry exists:

  • Run type NAME to see how Bash resolves the name.
  • Use help NAME when it is a Bash builtin.
  • Try NAME --help when an external program supports that convention.
  • Check whether your distribution offers a separate documentation package.

Checktype cd reports that cd is a Bash builtin, and no separate man page is available. Which command should you try next?

Summary

You can now locate and navigate installed manual documentation.

  1. Open a page by topic name.
  2. Search and move through a page in the usual pager.
  3. Quit the pager and return to the shell.
  4. Select a numbered manual section.
  5. Choose another help source when a page is unavailable.