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 “
|Description||Whatis (One-Line Command Defination)|
|Root or Sudo Privileges||Yes (for database update)|
|Host System and Architecture||Ubuntu 22.10 (x64)|
|OS Compatibility||Ubuntu, Manjaro, Fedora, etc.|
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
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
The above pwd command is used as an argument to get the description.
$ whatis nano vim
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
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
Interpreting Each Keyword as a Regex
-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 “
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
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
To avoid truncating the output to the terminal width, use the “
-l” or “
--long” flag with your argument.
$ whatis -l nano
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
If the keyword is not found in the specified list of sections, it will throw a “nothing appropriate” error.
$ whatis -s 3 nano
Browsing Through a Different Collection of Colon-Delimited Manual Page Hierarchies
By default, whatis uses the “
$MANPATH” environment 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
Temporarily Overriding the Determined Value
Use the “
-L” or “
--locale” flag to define the locale for this search.
$ whatis nano -L locale
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.