makewhatis Command in Linux



makewhatis is a Linux command that creates or updates a whatis database on Unix-like operating systems. The whatis database stores brief descriptions of commands and their manual pages, which can be viewed using the whatis command.

The makewhatis command scans the system's manual pages and creates or updates this database. It helps users quickly find one-line summaries of commands and files without reading the entire manual. System administrators usually run this command to ensure the database remains updated.

Table of Contents

Here is a comprehensive guide to the options available with the makewhatis command −

What is whatis Database?

The whatis database is a system-created resource used by the whatis command on Unix-like systems to describe commands and files briefly. It stores one-line summaries of manual pages, enabling users to grasp the command's purpose quickly without reading the entire manual.

Understanding makewhatis Command

The makewhatis command scans all the manual pages in the specified sections of manpath or the preformatted pages in catpath. It then adds an entry to the whatis database for each page, with the page name and a brief description separated by a dash. This description is pulled from the "NAME" section of the manual page.

Since different languages may have different terms for the "NAME" section, makewhatis also recognizes the corresponding terms in languages such as Czech, Italian, Finnish, French, German, and Spanish. If no manpath is provided, it defaults to /usr/man.

Syntax of makewhatis Command

The basic syntax of using the Linux makewhatis command is shown below −

makewhatis [-u] [-v] [-w] [-s sections ] [-c [catpath]] [manpath]

makewhatis Command Options

The table below shows all the options that are supported by the Linux makewhatis command −

Option Description
-u Refreshes the database to include pages updated in the past 24 hours.
-v Provides detailed information during execution.
-w Uses the manual paths retrieved from the man --path command.
-s sections Limits the search to specific sections within the manual or preformatted paths. If not specified, it checks the MANSECT environment variable or, as a fallback, the MANSECT configuration in man.conf.
-c catpath Examines preformatted manual pages in the specified catpath. If no path is given, it defaults to the first available directory, such as /usr/man/preformat or /usr/man.

How to install makewhatis Command in Linux?

By default, the makewhatis command is not generally pre-installed on many Linux distributions. On many systems, you can install the mandoc utility (which includes makewhatis) to get the command. However, in some cases, the makewhatis functionality might be provided by other packages, like man-db or man.

To install makewhatis command on Linux, you can use the following command −

sudo apt install mandoc
makewhatis Command in Linux1

Similarly, you can use the dnf package manager to get this utility on Fedora, CentOS, or RHEL −

sudo dnf install mandoc

Verify makewhatis installation

Once makewhatis is installed, you can access its general manual page to verify its installation and get detailed information about how to use the command. To do this, you can use the man command −

man makewhatis
makewhatis Command in Linux2

Examples of makewhatis Command in Linux

After installing makewhatis, you can use this command to create or update the whatis database, as demonstrated in the following examples −

Create or Update the Database

Run the makewhatis command without any option to scan all manual pages and update the whatis database −

sudo makewhatis

Update Recently Changed Pages

Run the makewhatis command with the -u option to refresh the database with manual pages modified in the last 24 hours −

sudo makewhatis -u

Using Custom Manual Paths

You can also specify the custom manual paths with the makewhatis command as follows −

sudo makewhatis /usr/share/man

This command updates the whatis database for manual pages located in the /usr/share/man directory.

Specify Sections to Scan

You can also limit the update to specific manual sections. For this purpose, you must execute the makewhatis command with the -s option followed by the section numbers −

sudo makewhatis -s 1,8

This command updates the manual page index database for sections 1 (user commands) and 8 (system administration commands).

Process Preformatted Pages

You can execute the makewhatis command with the -c option to include preformatted manual pages −

sudo makewhatis -c /usr/local/man/preformatted

This command creates or updates the whatis database specifically for preformatted manual pages located in the /usr/local/man/preformatted directory.

Modern Alternative to makewhatis Command

mandb

Many Linux systems now use mandb instead of makewhatis because it offers better features and updates automatically.

You can install it on Debian-based systems using sudo apt install man-db. To update the whatis database, simply run sudo mandb, which scans and updates the database more efficiently than makewhatis.

The key benefits of mandb include automatic updates during system maintenance and support for advanced formatting and custom settings. Overall, mandb is a faster and more reliable tool for managing manual page summaries, which makes it easier to find command information.

Conclusion

The makewhatis command is a useful Linux utility for creating or updating the whatis database, which stores concise descriptions of commands and their manual pages.

In this tutorial, we explained the purpose of the whatis database, the syntax and options of makewhatis, and how to install and use it effectively on Linux systems. Additionally, we explored various examples, including updating specific sections, handling preformatted pages, and using custom manual paths. Lastly, we highlighted mandb as a modern and efficient alternative to makewhatis for managing manual page summaries.

Advertisements