In Linux, the “whatis” command is used to offer a one-line description of command-line programs or a flag (i.e., all-text mode programs) and other topics related to Linux and other Unix-like OS. For example, each manual section in Linux contains some definitions. This command looks for the manual and displays the description of the given keyword.
It completes this by searching the short descriptions in the whatis database for each keyword provided as an argument (i.e., input data). This database contains just the title, section number, and description from the NAME section of each page in the man manual built into most Unix-like systems.
The syntax of the “whatis” command is:
For example, the following whatis command provides a single line summary of the head command (which by default displays the first ten lines of each file that is provided to it as an argument):
whatis can be used to search for information about multiple topics simultaneously. For example, the following would provide information about both head and tail (which by default reads the final ten lines of files):
whatis head tail
What is Man Command in Linux [aka Manual Pages]?
Man pages or manual pages are one of the most helpful resources to learn about a particular command from the terminal. A man page of a command contains a lot of descriptions about the command. In addition, there may be a time when you are stuck while executing a command; in such cases, you can simply access the manual page to get more information about that command.
To explore a manual page of any command, execute the command as follows:
man command_ name
The above command will work for all the Linux commands. Consider the below output:
The above output displays the manual page of the cat command. Similarly, we can list the manuals of any command in Linux.
How to use whatis command
If you want to know about any command in Linux OS, simply enter the name of the command or tool as a parameter:
$ whatis ls
The following output was produced by the aforementioned command:
ls (1) - list directory contents
How to get information of multiple commands
If you want to know the information about multiple commands simultaneously, enter all the names as input:
$ whatis ls cp rm mv
And here’s the output produced by this command:
ls (1) - list directory contents cp (1) - copy files and directories rm (1) - remove files or directories mv (1) - move (rename) files
So, above can see the whatis command handles multiple inputs easily.
Various options of the whatis command
Let’s discuss the various options of the “whatis” command:
- –?-h, –help
- D, –debug
- -v, verbose
- –r, regex
- -w, a wildcard
- -l, long
- -s, –section=LIST
- -m, –system=SYSTEM
- –M, –manpath=PATH
- -L, –locale=LOCALE
- -L, –locale=LOCALE
Use “–help” or “?” with whatis command to get help. Run any one command from them:
$ whatis -? $ whatis –help
Use the “-d” option to get debugging information:
$ whatis -d pwd
Use the “-v” option to get verbose detail of a command:
$ whatis –v pwd
Each name is interpreted as a regular expression with this option. When the name matches, the connection will be made:
$ whatis –r pwd
-w, a wildcard
Each name is interpreted as a sequence containing shell-style wildcards with this option. An extended name should be matched to the page name:
$ whatis -w pwd
This option will not trim output to suit the width of the terminal:
$ whatis -l
Use the “-s” option to check the manual sections specified. The section list is divided by a colon or a comma. If a list entry has any perspective section. Then it will display the information of a given keyword. Otherwise, it will display nothing appropriate:
$whatis –s 4 reboot
$ whatis 2x reboot
Using the “-m” NewOS option to scan for the names of NewOS’ manual page. NewOS is a Linux operating system.
$ whatis -m NewOS rmdir
The “-M” option allows you to browse through a different collection of colon-delimited manual page hierarchies:
$ whatis name –M --mathpath=/lib/pwd
Use the “-L” option to override the given keyword temporarily. Locale is directly supplying a string to whatis:
$ whatis ps -L locale
This option will exit after printing quick usage information:
$ whatis --usage
To display the version information, use “–V” with the “whatis” command option:
$ whatis -V
The Bottom Line
The whatis command helps in getting a short explanation of any command line. It goes through the manuals of all the commands and displays a brief description of the given keyword. First, we covered the usage of the “whatis” command and its several options.