> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# System Documentation Part 2

> Guide to using man pages, apropos, mandb, and shell tab completion to discover and learn command usage interactively.

When you forget the name of a command, the man pages, apropos, and shell completion are the fastest ways to rediscover it. This guide summarizes how to read man pages, search the man database, and use tab completion to build commands interactively.

## Man page sections — quick reference

The `man` manual is divided into numbered sections. Here’s a concise reference:

| Section | Content |
| -: | - |
| 1 | Executable programs or shell commands |
| 2 | System calls (kernel-provided functions) |
| 3 | Library calls (program library functions) |
| 4 | Special files (usually found in `/dev`) |
| 5 | File formats and conventions (e.g. `/etc/passwd`) |
| 6 | Games |
| 7 | Miscellaneous (macro packages, conventions), e.g. `man(7)` |
| 8 | System administration commands (usually only for root) |
| 9 | Kernel routines (non-standard on some systems) |

You can request a specific section when a name exists in multiple sections. For example:

```shell theme={null}
$ man 1 printf   # the userland printf command
$ man 3 printf   # the library printf function
```

## Read a man page (example: `man` and `journalctl`)

Running `man man` shows the section table (the example above), then details on using `man`.

A typical man page (example: `journalctl`) includes NAME, SYNOPSIS, and DESCRIPTION sections:

```text theme={null}
JOURNALCTL(1)                          journalctl                          JOURNALCTL(1)

NAME
       journalctl - Query the systemd journal

SYNOPSIS
       journalctl [OPTIONS...] [MATCHES...]

DESCRIPTION
       journalctl may be used to query the contents of the systemd(1) journal as written by systemd-journald.service(8).

       If called without parameters, it will show the full contents of the journal, starting with the oldest entry collected.

       If one or more match arguments are passed, the output is filtered accordingly. A match is in the format "FIELD=VALUE", e.g. "_SYSTEMD_UNIT=httpd.service".
       See systemd.journal-fields(7) for a list of well-known fields.
```

Man pages often include long option lists and examples — read `SYNOPSIS` for usage patterns and `DESCRIPTION` for context.

## Find commands with apropos

If you vaguely remember a command’s purpose but not its name, `apropos` searches the short descriptions (the same text `man -f` shows).

Search for related terms. Example: to find commands about directories, searching `director` often matches both `directory` and `directories`:

```shell theme={null}
$ apropos director
ls (1)                  - list directory contents
ls (1p)                 - list directory contents
mcd (1)                 - change MSDOS directory
mdeltree (1)            - recursively delete an MSDOS directory and its contents
mdir (1)                - display an MSDOS directory
mdu (1)                 - display the amount of space occupied by an MSDOS directory
mkdir (1)               - make directories
mkdir (1p)              - make directories
mkdir (2)               - create a directory
mkdirat (2)             - create a directory
```

If you want only command-line utilities (sections 1 and 8) — excluding kernel/library entries — restrict the search with `-s`:

```shell theme={null}
$ apropos -s 1,8 director
ls (1)                  - list directory contents
mcd (1)                 - change MSDOS directory
mdeltree (1)            - recursively delete an MSDOS directory and its contents
mdir (1)                - display an MSDOS directory
mdu (1)                 - display the amount of space occupied by an MSDOS directory
mkdir (1)               - make directories
```

Notes:

* `apropos` depends on a man-page database. On fresh systems that database might not exist. If `apropos` errors, create or update the database:

```shell theme={null}
$ sudo mandb
```

On long-running systems this is usually maintained automatically.

Tip: choose word stems that match both singular and plural forms (e.g., `director` vs `directory`) to broaden results.

## Interactive discovery with tab completion

Modern shells and command packages provide rich completion support — use Tab to discover commands, subcommands, options, filenames, and directories.

Examples to try in an interactive shell:

* Type `systemc` then press Tab to autocomplete to `systemctl` (if available).
* Type `systemctl` followed by a space and press Tab twice to list available subcommands and options. Example output:

```text theme={null}
$ systemctl
add-requires        emergency           isolate              poweroff           show
add-wants           enable              is-system-running    preset             show-environment
cancel              exit                kexec                reboot             start
cat                 force-reload        kill                 reenable           status
condreload          get-default         link                 reload             stop
condrestart         halt                list-dependencies    reload-or-restart  suspend
condstop            help                list-jobs            rescue             switch-root
```

You can complete fragments too: typing `systemctl list-dep` then pressing Tab will finish to `systemctl list-dependencies`.

Tab completion also works for filesystem paths and long filenames:

```shell theme={null}
$ ls /u<Tab>
$ ls /usr/<Tab><Tab>
# lists entries like:
# With a long filename like WordPress_archive.tgz:
$ ls WOR<Tab>
# autocompletes to WordPress_archive.tgz
```

## Learn by doing: use man pages and --help together

Man pages and `--help` output can be dense. A recommended learning loop:

1. Pick a command you know nothing about.
2. Read `man <command>` and `command --help`.
3. Try to accomplish a small task using only that material.

Example: `grep` man output includes SYNOPSIS, DESCRIPTION, and commonly used options. Excerpt:

```text theme={null}
SYNOPSIS
    grep [OPTION...] PATTERNS [FILE...]
    grep [OPTION...] -e PATTERNS ... [FILE...]
    grep [OPTION...] -f PATTERN FILE ... [FILE...]

DESCRIPTION
    grep searches for PATTERNS in each FILE. PATTERNS is one or more patterns separated by newline characters,
    and grep prints each line that matches a pattern.

OPTIONS
    --help                 Output a usage message and exit.
    -V, --version          Output the version number of grep and exit.

Pattern Syntax
    -E, --extended-regexp  Interpret PATTERNS as extended regular expressions (EREs).
    -F, --fixed-strings    Interpret PATTERNS as fixed strings, not regular expressions.
    -G, --basic-regexp     Interpret PATTERNS as basic regular expressions (BREs). This is the default.
    -P, --perl-regexp      Interpret PATTERNS as Perl-compatible regular expressions (PCREs).

File handling
    -d, --directories=ACTION   how to handle directories; ACTION is 'read', 'recurse', or 'skip'
    -r, --recursive           like --directories=recurse
    -R, --dereference-recursive  likewise, but follow all symlinks
    --include=GLOB            search only files that match GLOB
    --exclude=GLOB            skip files that match GLOB
    -l, --files-with-matches  print only names of FILEs with selected lines
    -c, --count               print only a count of selected lines per FILE

Context control:
    -B, --before-context=NUM  print NUM lines of leading context
    -A, --after-context=NUM   print NUM lines of trailing context
    -C, --context=NUM         print NUM lines of output context
```

Man pages may also include reporting and help URLs in angle brackets; those are part of the documentation and safe to read.

## Practice and confidence

Use man pages, `apropos`, `--help`, and tab completion together. Small time savings from knowing these tools compound — whether you’re troubleshooting or preparing for an exam.

<Callout icon="lightbulb" color="#1CB2FE">
  Tip: If `apropos` returns nothing, run `sudo mandb` to build the man-db. Restrict `apropos` searches to relevant sections (for example: `-s 1,8`) to avoid results from kernel or library pages.
</Callout>

## Links and references

* [man — format of man pages and man command](https://man7.org/linux/man-pages/man1/man.1.html)
* [apropos / man -f](https://man7.org/linux/man-pages/man1/apropos.1.html)
* [mandb — create or update the man database](https://man7.org/linux/man-pages/man8/mandb.8.html)
* [systemd and journalctl documentation](https://www.freedesktop.org/wiki/Software/systemd/)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/crash-course-linux-for-absolute-beginners/module/ad9775dd-41c2-4d59-ae9a-6b18672ecbac/lesson/47c7e4af-464a-45df-98f7-ab118a6a1f09" />

  <Card title="Practice Lab" icon="flask-conical" cta="Learn more" href="https://learn.kodekloud.com/user/courses/crash-course-linux-for-absolute-beginners/module/ad9775dd-41c2-4d59-ae9a-6b18672ecbac/lesson/ca9333f8-db4f-41c6-abdb-c036f9219aee" />
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.