Skip to content

Linux Foundations / Find your way around Linux ยท Step 27 of 63

Lesson: manSwitch
โ† Linux Foundations

Shell and files

man

Read manual pages with man, understand their sections and search by keyword.

man shows the manual page for a command, configuration file or programming function. Manual pages are installed with the software, so they describe the version on your machine and work offline.

Opening a page

$ man ls

The page usually opens in less. Press Space to move down, /word to search, n for the next match and q to quit.

The layout of a page

Common headings are:

  • NAME: the command and a one line summary.
  • SYNOPSIS: how to type it.
  • DESCRIPTION: what it does, often with the options.
  • EXAMPLES and SEE ALSO: present on many pages, not all.

In the SYNOPSIS, square brackets mark optional parts and ... means repeatable.

Sections

The manual is divided into numbered sections. The most useful are:

  • 1: user commands
  • 5: file formats and configuration files
  • 8: system administration commands

The same name can exist in more than one. passwd is both a command and a file:

$ man passwd
$ man 5 passwd

The first normally shows the command, and the second shows the format of /etc/passwd. A reference such as crontab(5) means the crontab page in section 5.

Searching by keyword

If you do not know the command name, search the page summaries:

$ man -k "list directory"
dir (1)              - list directory contents
ls (1)               - list directory contents
vdir (1)             - list directory contents

Results depend on which packages are installed. man -k does the same job as apropos. If it finds nothing on a new system, the page index may need building with sudo mandb on many Linux distributions.

When there is no page

$ man cd
No manual entry for cd

Shell built-ins are often documented through help cd or in man bash instead, though some distributions provide their own pages for them. Minimal installs and containers may remove manual pages altogether to save space.

Try it

  1. Open man ls and search for sort.
  2. Compare man passwd with man 5 passwd.
  3. Run man -k directory.
  4. Read man man to learn about the other sections.

Check your understanding

man

All 5 sections ยท no timer

Unlimited retries

Questions from every section are combined into one assessment. Answer them all correctly to complete the article.

Your completion saves in this browser. Sign in to sync it to your account.