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
Description | Whatis (One-Line Command Defination) |
Difficulty Level | Low |
Root or Sudo Privileges | Yes (for database update) |
OS Compatibility | Ubuntu, Manjaro, Fedora, etc. |
Prerequisites | whatis |
Internet Required | No |
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:
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:
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:
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:
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:
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.
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:
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:
To avoid truncating the output to the terminal width, use the “-l
” or “--long
” flag with your argument.
$ whatis -l nano
Output:
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:
If the keyword is not found in the specified list of sections, it will throw a “nothing appropriate” error.
$ whatis -s 3 nano
Output:
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
Output:
Temporarily Overriding the Determined Value
Use the “-L
” or “--locale
” flag to define the locale for this search.
$ whatis nano -L locale
Output:
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.