Beginners Guide for Whatis Command on Linux

Linux TLDR
Last Updated:
Reading time: 3 minutes

The whatis command is used to fetch a one-line description of the specified command from the manual pages.

The search query (command) you will use as an argument to get the description will be looked up in the index database maintained by the “maindb” program.

Tutorial Details

DescriptionWhatis (One-Line Command Defination)
Difficulty LevelLow
Root or Sudo PrivilegesYes (for database update)
OS CompatibilityUbuntu, Manjaro, Fedora, etc.
Prerequisiteswhatis
Internet RequiredNo

Syntax of the Whatis Command

The whatis command takes two arguments: one is the option, and the other is the keyword.

$ whatis [OPTION] [KEYWORD]

You can specify multiple keywords to get a description by using a space as a separator.

Whatis: returns all commands as “nothing appropriate”

While using the whatis command, if it returns all the command’s output as “nothing appropriate”, then execute the following command to regenerate the database indexes with sudo.

$ sudo mandb

Output:

Regenerating the database indexes

After the database indexes are generated again, check the description of any command.

Fetching Single or Multiple Commands Description

Specify the tool or command name as an argument to get the one line description from the manual page.

$ whatis pwd

Output:

Checking the short info of pwd command using whatis command

The above pwd command is used as an argument to get the description.

If you want to fetch multiple command descriptions, like Nano and Vim, then specify each of them with a space as a separator.

$ whatis nano vim

Output:

Checking the multiple commands info using whatis command

Displaying the Command Debugging Information

Use the “-d” or “--debug” flag and specify the command to get the descriptive debugging information that includes the compilation paths, find search path, warning, name, section, id, mtime, and many more.

$ whatis -d nano 

Output:

Checking the command debugging information using whatis command

The above command given comprehensive debugging information for the nano command (replace with your command).

Displaying the Command Verbose Information

Use the “-v” or “--verbose” flag to get the specified command’s verbose information.

$ whatis -v nano

Output:

Checking the command verbose information using whatis command

Interpreting Each Keyword as a Regex

The “-r” or “--regex” flag will interpret each name as a regular expression by searching for the match of the specified name rigorously on any part of the manual page.

$ whatis -r "^na"

The above command will return all the results that start with the “na” keyword.

regex filter in whatis command

Interpreting Each Keyword as a Pattern Containing Shell Style Wild Cards

Use the “-w” or “--wildcard” to interpret each keyword as a pattern containing shell style wildcards.

It will check each keyword for a match from the entire manual page, making the search slower to return the results.

$ whatis -w nano

Output:

Interpreting each keyword as pattern in whatis command

Do Not Trim the Output to the Terminal Width

If you reduce your terminal width, the description will be trimmed with “” as shown.

$ whatis -f nano

Output:

Avoid triming the output in whatis command

To avoid truncating the output to the terminal width, use the “-l” or “--long” flag with your argument.

$ whatis -l nano

Output:

Avoid triming the output based on terminal width in whatis command

Searching the Keyword in the Specified Section

The manual page is divided into multiple sections; if you want to search your keyword on a specific list of sections, use the “-s” or “--section” or “--sections” flag and specify each list with a comma (“,“) as a separator.

$ whatis -s 1 nano

Output:

Checking specific keyword in section

If the keyword is not found in the specified list of sections, it will throw a “nothing appropriate” error.

$ whatis -s 3 nano

Output:

Checking specific keyword on invalid section

Browsing Through a Different Collection of Colon-Delimited Manual Page Hierarchies

By default, whatis uses the “$MANPATHenvironment variable unless the value is empty or unset; in that case, it will determine the appropriate manpath based on your “$PATH” environment variable.

To override this option, use a different set of colon-delimited manual page hierarchies to search.

$ whatis nano -M --manpath=/lib/man-db/mandb

Output:

Checking command info from custom database

Temporarily Overriding the Determined Value

Use the “-L” or “--locale” flag to define the locale for this search.

$ whatis nano -L locale

Output:

Performing locale search in whatis command

Exit Status of Whatis Command?

The exit status might come into use when you use the whatis in your shell script to control the follow of your script.

The whatis command has four exit statuses, followed by:

  • 0 – Program successfully executed.
  • 1 – Usage, syntax, or configuration file error.
  • 2 – Operational error.
  • 16 – Nothing matched the specified criteria.

That’s the end.

If you have questions related to this topic, feel free to ask them in the comment section.

Join The Conversation

Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.