Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

mandb

Build or update the search database of the man pages (used by man -k, apropos and whatis).

Level
RHCSA exam
Group
Shell and help
Needs root
Yes
Package
man-db

What it does

man -k and apropos do not read every manual page; they search a small database with the short descriptions. mandb creates and updates that database.

On RHEL a timer updates it every day. But right after an install, or after you install new packages, the database can be empty or old. Then man -k says "nothing appropriate". Run mandb as root to fix it.

How to write it

mandb [-dqsucpt?V] [-C FILE] [MANPATH]
mandb [-dqsut] [-C FILE] -f FILENAME ...

Options 12

Most used

-c, --create
Build the databases from zero, even if they exist.
-q, --quiet
Only print warnings and errors.
-u, --user-db
Build only the database of your user, not the system databases.
-f, --filename file
Update only the entry of this one page file.
-s, --no-straycats
Do not look for formatted pages without a source.
-p, --no-purge
Do not remove entries of pages that were deleted.
-t, --test
Check the pages for problems; do not build a database.
-d, --debug
Print debug information.
-C, --config-file=file
Use another configuration file.
-?, --help
Show help.
--usage
Show a short usage message.
-V, --version
Show the version.

Examples 11

$ run as a normal user# run as root (or with sudo)

  1. 1Update the database

    mandb

    Takes a few seconds. After this, man -k finds new pages.

  2. 2Fix "nothing appropriate" from man -k

    man -k partition
    partition: nothing appropriate.
    mandb
    man -k partition

    Typical on a fresh system or in the exam: build the database once.

  3. 3Build everything from zero

    mandb -c

    Use it when the database seems broken.

  4. 4Update quietly in a script

    mandb -q

    Only errors are printed. Good after installing many packages.

  5. 5Update after you add your own man page

    cp mytool.8 /usr/local/share/man/man8/ && mandb -q
    man -k mytool

    Your page appears in the search.

  6. 6Update only the entry of one file

    mandb -f /usr/local/share/man/man8/mytool.8

    Faster than a full run.

  7. 7Build a database for your own pages (no root)

    mandb -u

    For pages in your home folder (for example in ~/.local/share/man).

  8. 8Check the pages for errors without changing anything

    mandb -t

    Reports broken or wrong pages.

  9. 9Check the timer that updates the database every day

    systemctl list-timers | grep man-db

    If the timer is missing or disabled, the database gets old.

  10. 10Update the database after a big dnf install in a template

    dnf install -y bind-utils nfs-utils && mandb -q

    A ready-to-use VM template should have a fresh man database.

  11. 11See which folders mandb indexes

    manpath

    Prints the folders that man and mandb use.

Watch out

  • mandb does not install man pages. If a page is missing, install the package that has it.
  • Run it as root to update the system databases.

Files

/var/cache/man/
The databases (index.db files).
/etc/man_db.conf
Which folders are indexed.

Tips to remember

Full manual

This page explains the command in simple words. The original manual has every detail.

In your terminal: man 8 mandb