Beginners Guide for Whatis Command in Linux

Linux TLDR
Last Updated:
Reading time: 4 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)
Host System and ArchitectureUbuntu 22.10 (x64)
OS Compatibility Ubuntu, Manjaro, Fedora, etc.
Prerequisiteswhatis
Internet RequiredNo
Discussed Tools in this Article

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 commands’ output as “nothing appropriate“, then execute the following command to regenerate the database indexes with sudo.

$ sudo mandb

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
pwd (1)              - print name of current/working directory

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
nano (1)             - Nano's ANOther editor, inspired by Pico
vim (1)               - Vi IMproved, a programmer's text editor

Also Read: Beginners Guide for Which Command in Linux

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 
From the config file /etc/manpath.config:
  Mandatory mandir `/usr/man'.
  Mandatory mandir `/usr/share/man'.
  Mandatory mandir `/usr/local/share/man'.
  Path `/bin' mapped to mandir `/usr/share/man'.
  Path `/usr/bin' mapped to mandir `/usr/share/man'.
  Path `/sbin' mapped to mandir `/usr/share/man'.
  Path `/usr/sbin' mapped to mandir `/usr/share/man'.
  Path `/usr/local/bin' mapped to mandir `/usr/local/man'.
  Path `/usr/local/bin' mapped to mandir `/usr/local/share/man'.
  Path `/usr/local/sbin' mapped to mandir `/usr/local/man'.
  Path `/usr/local/sbin' mapped to mandir `/usr/local/share/man'.
  Path `/usr/X11R6/bin' mapped to mandir `/usr/X11R6/man'.
  Path `/usr/bin/X11' mapped to mandir `/usr/X11R6/man'.
  Path `/usr/games' mapped to mandir `/usr/share/man'.
  Path `/opt/bin' mapped to mandir `/opt/man'.
  Path `/opt/sbin' mapped to mandir `/opt/man'.
  Global mandir `/usr/man', catdir `/var/cache/man/fsstnd'.
  Global mandir `/usr/share/man', catdir `/var/cache/man'.
  Global mandir `/usr/local/man', catdir `/var/cache/man/oldlocal'.
  Global mandir `/usr/local/share/man', catdir `/var/cache/man/local'.
  Global mandir `/usr/X11R6/man', catdir `/var/cache/man/X11R6'.
  Global mandir `/opt/man', catdir `/var/cache/man/opt'.

The above command will give you 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
nano (1)             - Nano's ANOther editor, inspired by Pico

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"
NAN (3)              - floating-point constants
name_to_handle_at (2) - obtain handle for a pathname and open file via a handle
namei (1)            - follow a pathname until a terminal point is found
namespace.conf (5)   - the namespace configuration file
namespaces (7)       - overview of Linux namespaces
nan (3)              - return 'Not a Number'
nanf (3)             - return 'Not a Number'
nanl (3)             - return 'Not a Number'
nano (1)             - Nano's ANOther editor, inspired by Pico
nanorc (5)           - GNU nano's configuration file

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

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
nano (1)             - Nano's ANOther editor, inspired by Pico

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
nano (1)             - Nano's ANOther editor, i...

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

$ whatis -l nano
nano (1)             - Nano's ANOther editor, inspired by Pico

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
nano (1)             - Nano's ANOther editor, inspired by Pico

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

$ whatis -s 3 nano
nano: nothing appropriate.

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
nano: nothing appropriate.

Temporarily Overriding the Determined Value

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

$ whatis nano -L locale
nano (1)             - Nano's ANOther editor, inspired by Pico

Also Read: What is Exit Status Code ($?) in Linux

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.