The whatis command in Linux provides the one-line description of keywords from their associated man page. In brief, the whatis command searches for the Manual Page that matches the given name and outputs its definition. In this article, I will explain various applications of the whatis command with practical examples.
A. Description
The whatis command in Linux displays the short description of a keyword available on its man page. While using special or wildcard characters, you must quote the name or use escape (\) to stop the shell from interpreting them.
B. Syntax
The syntax of the whatis command in Linux simply contains single or multiple options and then the desired Keywords.
whatis [OPTION]... KEYWORD...
C. Options
The whatis command in Linux offers multiple options to enhance user experience. Below you will find the most useful options of the command. For further details, you can always look at the man page.
man whatis
Useful Options
- -d/–debug: Displays debugging messages.
- -l/–long: Disable trimming output to the terminal width.
- -L/–locale: Searches in the defined locale.
- -m/–systems: Search in Manual Pages of other Systems.
- -M/–manpath: Set Manual Page search path.
- -r/–regex: interprets the given name as a regular expression.
- -s/–section: Search only in specified sections.
- –usage: Print a short usage message.
- -v/–verbose: Display verbose warning messeges.
- -w/–wildcard: Search keywords with wildcard characters.
NB: The options in Linux CLI (Command Line Interface) are all case-sensitive, So be cautious while using them.
Practical Examples of the “whatis” Command in Linux
The whatis command is a convenient command to learn about the KEYWORDs associated with Linux. Some of the most useful applications of the whatis command have been illustrated below with practical examples.
Example 1: Displaying a Short Description of a Keyword Using the “whatis” Command in Linux.
You can learn about any command or keyword briefly by using the whatis command in Linux. It will provide the short description found on the man page of the associated keyword. In this example, I will display the short description of the pwd command. You can do the same by following the steps below.
Steps to Follow:
➊ At first open the Ubuntu Terminal.
➋ Type the following command in the command prompt:
whatis pwd
➌ Now, press the ENTER button.
Output:
In the given image, you can see that I have shown the description of the pwd command.
Example 2: Displaying Short Description of Multiple Keywords Using the “whatis” Command in Linux.
You can view the short description from the man page of multiple keywords at the same time using the whatis command in Linux. In this example, I will show you the definition of the pwd, touch, and mkdir commands. To do the same you can follow the steps below.
Steps to Follow:
➊ Open the Ubuntu Terminal.
➋ Type the following command in the command prompt:
whatis pwd touch mkdir
➌ Press the ENTER button.
Output:
In the following image, you can see that I have shown the short descriptions of the desired commands.
Example 3: Access Debugging Information of a Keyword Using the “whatis” Command in Linux.
You can display debugging information of a keyword by using the whatis command in Linux. To achieve this result you will need to use the -d option. In this example, I will be displaying the debugging messages of the mkdir command. You will be able to do the same by following the process below.
Steps to Follow:
➊ Launch the Ubuntu Terminal.
➋ Type the following command in the command line:
whatis -d mkdir
➌ Hit the ENTER button.
Output:
In the next images, you can see that I have shown the debugging information of the mkdir command.
Similar Readings
- The “man” Command in Linux [6 Practical Examples]
- The “history” Command in Linux [6 Practical Examples]
- The “cal” Command in Linux [7 Practical Examples]
- The “bc” Command in Linux [10+ Practical Examples]
Example 4: Displaying Verbose Details of a Keyword Using the “whatis” Command in Linux.
You can view a verbose description of a command by using the whatis command in Linux with the option -v. In this example, I will display the verbose description of the touch command. You can do the same by following the given steps.
Steps to Follow:
➊ At first open the Ubuntu Terminal.
➋ Type the following command in the command prompt:
whatis -v touch
➌ Now, press the ENTER button.
Output:
In the image below, you can see that I have shown the verbose description of the touch command.
Example 5: Extracting Every Description Containing the Specified Keyword.
You can search for any keyword short description that contains the specific name using the whatis command in Linux. You can do so by using the option -r which interprets the given name as a regular expression. In this example, I find all the keywords and descriptions that have the keyword pwd. To do the same you can follow the steps below.
Steps to Follow:
➊ Go to the Ubuntu Terminal.
➋ Write the following command in the command prompt:
whatis -r pwd
➌ Press ENTER.
Output:
In the following image, you can see that I have shown the short descriptions of all the commands containing the name “pwd”.
Example 6: Searching for a Keyword Description With Wildcard Characters.
You can search for descriptions of keywords that contain certain characters by using the whatis command in Linux with the option -w. With this -w option, you can apply wildcard characters for searching. In this example, I will search for keywords that start with the string “pw”. To indicate any other string after “pw” I will use the wildcard character “*”. You can get the same results by following the given steps.
Steps to Follow:
➊ At first open the Ubuntu Terminal.
➋ Type the following command in the command prompt:
whatis -w “pw*”
➌ Now, press the ENTER button.
Output:
In the given image, you can see that I have found all the keywords and their descriptions that start with “pw”.
Example 7: Disabling Trimmed Output of the Description.
The whatis command in Linux generally truncates the output to the terminal width of one line. You can disable this trimming of the description using the -l option along with the command and eventually fit the whole sentence of that description. In this example, I will demonstrate disabling the trimming of the result by showing the short description of the cat command. You will be able to do the same by following the process below.
Steps to Follow:
➊ At first, launch the Ubuntu Terminal.
➋ Type the following command in the command prompt:
whatis -l cat
➌ Press the ENTER button.
Output:
In the image below, you can see in the 1st command without the -l option the output was truncated. But in the 2nd command when applied with the -l option you can get the full description.
Example 8: Searching For Keyword Description in the Specified Manual Section.
When you’re searching for a keyword description using the whatis command in Linux, you can specify certain section numbers of the man page to lookup for the description. You can pass the section number by using the option -s. In this example, I will search for the man command description in sections 1 and 7 of its man page. Follow the process below to do the same.
Steps to Follow:
➊ Launch the Ubuntu Terminal.
➋ Type the following command in the command prompt:
whatis -s 1,7 man
➌ Press ENTER.
Output:
In the following image, you can see that I have displayed the description of the man command from the specified sections.
Example 9: Searching for Keyword Description in Other Operating System’s Manual Page.
You can get access to other operating systems’ Manual Pages using the whatis command in Linux with the option -m. You must provide the specified system’s name along with the option. In this example, I will search for the touch command in NewOS‘s Manual Page. To achieve the same you may follow the given process.
Steps to Follow:
➊ Open the Ubuntu Terminal.
➋ Type the following command in the command line:
whatis -m NewOS touch
➌ Hit the ENTER button.
Output:
In the given image, you can see that I have shown a short description of the touch command from the NewOS‘s Manual Page.
Example 10: Searching for Keyword Description in an Alternate Set of Manual Page Hierarchies.
The whatis command in Linux by default looks for the short description in the $MANPATH environment variable. You can specify an alternate set of colon-delimited manual page hierarchies to search in using the -M option with this command. In this example, will set the search path to /lib/touch for getting the description of the command touch. To do the same you can follow the given steps.
Steps to Follow:
➊ Open the Ubuntu Terminal.
➋ Type the following command in the command line:
whatis -M --manpath=/lib/touch
➌ Hit the ENTER button.
Output:
In the following image, you can see that the output did not return any useful output as the does not contain the description of the touch command.
Similar Readings
- The “cron” Command in Linux [3 Practical Examples]
- The “crontab” Command in Linux [10 Practical Examples]
- The “date” Command in Linux [8+ Practical Examples]
- The “ncal” Command in Linux [8 Practical Examples]
Example 11: Directly Supplying a Keyword to the “whatis” Command.
The whatis command in Linux generally determines the current locale by calling another function and checking various environment variables. You can directly supply a locale string to the whatis command using the -L option. In this example, I will directly send the string “pwd” to the whatis command. You may follow the given steps to do the same.
Steps to Follow:
➊ Go to the Ubuntu Terminal.
➋ Type the following command in the command line:
whatis pwd -L locale
➌ Press ENTER.
Output:
In the following image, you can see that I directly supplied the pwd command to the whatis command for finding its short description.
Example 12: Displaying a Usage Message Using the “whatis” Command in Linux.
You can display a short usage message of the whatis command with the help of the –usage option. In this example, I will be displaying the usage message on my terminal. You will be able to view the same message by following the below process.
Steps to Follow:
➊ Launch the Ubuntu Terminal.
➋ Type the following command in the command line:
whatis --usage
➌ Hit the ENTER button.
Output:
In the below image, you can see that I have displayed a short usage message of the whatis command.
Conclusion
In this article, I presented the usefulness of the whatis command in Linux with some easy and practical examples. Using these examples, you will be able to utilize this command to learn more about the available keywords on the Linux distribution. I hope this writing will enrich your experience with the command line.
Similar Readings
- The “neofetch” Command in Linux [12+ Practical Examples]
- The “tree” Command in Linux [14 Practical Examples]
- The “whereis” Command in Linux [10 Practical Examples]
- The “which” Command in Linux [3 Practical Examples]
- The “at” Command in Linux [7 Practical Examples]
- The “tee” Command in Linux [4 Practical Examples]