The “whatis” Command in Linux [12 Practical Examples]

The whatis command in Linux provides the one-line man page description of keywords. Each command in Linux has some descriptive information within it. And, the whatis command searches for the Manual Page that matches the given keyword passed as an argument and outputs its description to assist users in getting to know the specified command in brief. However, while using special or wildcard characters, you must quote the name or use escape (\) to stop the shell from interpreting them.

In this article, I will explain various applications of the whatis command with 12 practical examples.

The Linux “whatis” Command Syntax

The syntax of the whatis command in Linux simply contains single or multiple options and then the desired Keywords.

whatis [OPTION]... KEYWORD...
Note: In the above syntax both the OPTION enclosed by square brackets means specifying an option is not mandatory and the 3 dots next to it indicates that multiple options can be utilized simultaneously. Similarly, multiple keywords can be used as well

The Linux “whatis” Command 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

Options

Description

-d/–debug Displays debugging messages.
-l/–long Disable trimming output to the terminal width.
-L/–locale Searches in the defined locale.
-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.
Note: The options in Linux CLI (Command Line Interface) are all case-sensitive, So be cautious while using them

12 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 12 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 a single-line 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 running the following command:

whatis pwd

In the given image, you can see that I have shown the description of the pwd command.Finding short description of a command using whatis command in linux.

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, type the below command in the prompt and press ENTER:

whatis pwd touch mkdir

In the following image, you can see that I have shown the short descriptions of the desired commands.Finding short description of multiple commands using whatis command in linux.

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 executing the command below:

whatis -d mkdir

In the next images, you can see that I have shown the debugging information of the mkdir command.Displaying debugging information of a command using whatis command in linux.


Similar Readings


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. For a similar output, run the following command:

whatis -v touch

In the image below, you can see that I have shown the verbose description of the touch command.Showing verbose description of a command using whatis command in linux.

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, run the command below in the prompt:

whatis -r pwd

In the following image, you can see that I have shown the short descriptions of all the commands containing the name “pwd”.Short description of all commands containing "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 running the command as follows:

whatis -w "pw*"

In the given image, you can see that I have found all the keywords and their descriptions that start with “pw”.Finding keyword descriptions with wildcard characters in its name using whatis command in linux.

Example 7: Disabling Trimmed Output

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 running this command below:

whatis -l cat

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.Diaabling trimmed description using whatis command in linux.

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 look 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. Run the command below to do the same:

whatis -s 1,7 man

In the following image, you can see that I have displayed the description of the man command from the specified sections.Searching keyword descriptions in specific sections using whatis command in linux.

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 run the given command:

whatis -m NewOS touch

In the given image, you can see that I have shown a short description of the touch command from the NewOS‘s Manual Page.Accessing other OS man page using whatis command in linux.

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 the below example, I will set the search path to /lib/touch to get the description of the command touch:

whatis -M --manpath=/lib/touch

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.Nothing appeared as the description of the touch command does not exist.


Similar Readings


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 run the following command to do the same:

whatis pwd -L locale

In the following image, you can see that I directly supplied the pwd command to the whatis command to find its short description.Directly passing keyword to the whatis command in linux.

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 after running the following command:

whatis --usage

In the below image, you can see that I have displayed a short usage message of the whatis command.Viewing usage short usage message using whatis command in linux.

Conclusion

In this article, I presented the usefulness of the whatis command in Linux with 12 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.

People Also Ask

How to use the whatis command in Linux?

Using the whatis command in Linux is very easy. Open the system terminal and type the command whatis followed by the name of the tool or command as its parameter. For example, to get the one-line description of the cp command, run the following command:

whatis cp

Does the Linux whatis command have the -help option?

Yes, it has. If you get stuck at some point in using the Linux whatis command, you can use the -h option with the command to get help. To display help on the terminal, run the following command:

whatis -h

You can also use the command whatis –help to do the same.

Can the Linux whatis command search for keywords or tools other than commands?

Yes. The whatis command in Linux not only prints the brief description of any mentioned commands but also provides information on functions. For example, run the following command to display a single-line definition of the printf function:

whatis printf

Output:

“format and print data”

How do I know the current version of the whatis command in Linux running on my system?

Just run the whatis -V command and get to know the version information that is currently running on your system. You can also use the –version option to achieve alike output.


Similar Readings

Rate this post
Anonnya Ghosh

Hello there! I am Anonnya Ghosh, a Computer Science and Engineering graduate from Ahsanullah University of Science and Technology (AUST). Currently, I am working as a Linux Content Developer Executive at SOFTEKO. The strong bond between Linux and cybersecurity drives me to explore this world of open-source architecture. I aspire to learn new things further and contribute to the field of CS with my experience. Read Full Bio

Leave a Comment