mandb

system managementlinux
The mandb command is one of the most frequently used commands in Linux/Unix-like operating systems. mandb The mandb command creates or updates the manual page index caches (databases) used by man, apropos, and whatis. It indexes the contents of all manual pages to enable fast searching based on names, descriptions, and keywords.

Quick Reference

Command Name:

mandb

Category:

system management

Platform:

linux

Basic Usage:

mandb [options] [arguments]

Common Use Cases

  • 1

    Manual database

    Update the manual database for faster command lookup

  • 2

    Performance

    Improve the speed of manual page searches

  • 3

    System maintenance

    Keep the manual database up-to-date

  • 4

    Scripting

    Use in shell scripts to update the manual database programmatically

Syntax

mandb [OPTION...]

Options

Option Description
-c, --create Create index databases if they don't exist
-d, --debug Print debugging information
-f, --force Forcefully reindex all entries, even if already up to date
-q, --quiet Run quietly, producing no warnings
-s, --no-straycats Don't process catpages that don't have source files
-t, --test Test run, just show what would be done
-u, --user-db Create a private user database only
-p, --no-purge Don't purge obsolete entries from the database
--help Display help information
--usage Display a short usage message

Examples

How to Use These Examples

The examples below show common ways to use the mandb command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

#

Basic Examples:

mandb

Update the manual page index caches for all directories specified in the man-db configuration file.

sudo mandb

Run with superuser privileges to ensure all manual page directories can be processed.

mandb -c

Check for consistency between the database and the filesystem, reporting any problems.

Advanced Examples:

mandb -f

Force recreation of all database entries, even if already up to date.

mandb -t

Create database caches for manual pages in all directories in the manpath (Test run).

mandb -q

Run quietly, showing only error messages.

mandb /usr/local/man

Process only the manual pages in the specified directory.

Try It Yourself

Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

Understanding Syntax

Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

Notes

Key Points:

  • The mandb command is also known as makewhatis on some systems
  • It creates and maintains the databases used by man -k, apropos, and whatis
  • Running mandb is necessary after installing new packages with manual pages
  • The command typically requires root privileges to update system-wide manual page databases
  • The databases are stored in /var/cache/man on most Linux systems

Cache Locations:

  • /var/cache/man: The primary location for system-wide man page index caches
  • ~/.cache/man: Location for user-specific manual page caches
  • /usr/share/man: Common directory containing manual pages that are indexed
  • /usr/local/man: Local manual pages that should be indexed

Common Use Cases:

  • Updating the manual page index after installing new software packages
  • Troubleshooting when man -k, apropos, or whatis commands don't return expected results
  • Creating private user databases for custom manual pages
  • Maintaining manual page databases on systems with frequent software updates
  • Repairing corrupted manual page databases

Related Commands:

  • man - Display manual pages
  • apropos - Search manual page names and descriptions
  • whatis - Display one-line manual page descriptions
  • catman - Create or update formatted versions of manual pages
  • makewhatis - Alternative name for mandb on some systems

Configuration Files:

  • /etc/man_db.conf: Main configuration file for man-db
  • /etc/manpath.config: Configuration file on some systems
  • MANPATH: Environment variable defining paths to search for manual pages

Tips & Tricks

1

Use the -c option to create the database

2

Use the -q option to run in quiet mode

3

Use the -v option to display verbose output

4

Use the -h option to display help

5

Use the -V option to display version information

Common Use Cases

Manual database

Update the manual database for faster command lookup

Performance

Improve the speed of manual page searches

System maintenance

Keep the manual database up-to-date

Scripting

Use in shell scripts to update the manual database programmatically

Documentation

Manage and maintain the manual database

Related Commands

These commands are frequently used alongside mandb or serve similar purposes:

Use Cases

1

Manual database

Update the manual database for faster command lookup

2

Performance

Improve the speed of manual page searches

3

System maintenance

Keep the manual database up-to-date

4

Scripting

Use in shell scripts to update the manual database programmatically

5

Documentation

Manage and maintain the manual database

Learn By Doing

The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the mandb command works in different scenarios.

$ mandb
View All Commands