Javatpoint Logo
Javatpoint Logo

Whatis command in Linux

The whatis command is used to get brief information about Linux commands or functions. It displays the manual page description in a single line of the command that passes with the whatis command. It searches for the strings that have been passed with it from its index databases. Its index database is maintained by the mandb program.

The whatis command selects a short description of the 'NAME' section in the manual page of the commands passed with it. It facilitates various command-line options to assist the user in getting a short description of the specified command.

Syntax:

To understand the whatis command, first, understand the manual pages:

What are the manual pages?

Manual pages or man pages are one of the most useful resources to learn about a particular command from the terminal. A man page of a command contains a lot of descriptions about the command. There may be a time when you 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:

The above command will work for all the Linux commands. Consider the below output:

Whatis command in Linux

The above output displays the manual page of the cat command. Similarly, we can list the manuals of any command in Linux.

Let's understand various usage of whatis command:

Basic use of whatis command

If it is used without any argument, it will display a brief description from the manual about the specified command in one line.

To display the description about the cat command, execute the command as follows:

Consider the below output:

Whatis command in Linux

Get information from a specific section

We can access the information from a specific section of the manual page. To access the information of a Linux command from a specific section of the manual page, execute the command with the "-s or --section" option. It will bound the whatis command to display the short description from the specified section of the manual page only.

Consider the below command:

The above command will display brief information about the cat command and functions of manual page 1 and page 2. Consider the below output:

Whatis command in Linux

Search information through the wild-card

We can also search Linux commands and functions using a wild card. To search commands and functions using a wild card, execute the command with "-w or -wildcard" option. It will search according to the specified wild card.

For example, if we want to search the commands and functions and display their short description as 'ab' or 'cd' pattern, then we will execute the command as follows:

The above commands will display the commands and functions with the matching patterns. Consider the below output:

Whatis command in Linux

As from the above output, the pattern ab matches with an Apache HTTP server benchmarking tool and cd matches with three different functions. The short description of these tools and functions can be seen in the above output.

Search information through the regular expression

We can search for functions and commands using a regular expression. To search commands and functions using a regular expression, execute the whatis command with the " -r or regex" option. It will search for functions and commands according to the specified regular expression. Thus, it provides a flexible search for the Linux system.

For example, if we want to search for the functions and commands according to the regular expression "^ab" or "^cd," then we will execute the command as follows:

The above commands will display the short description of the functions matching with expression 'ab' and 'cd'. Consider the below output:

Whatis command in Linux

As from the above output, the pattern ab matches with an Apache HTTP server benchmarking tool and cd matches with three different functions. The short description of these tools and functions can be seen in the above output.

Similarly, if we want to search for the function that matches with the regular expression 'cd$', execute the command as follows:

The above command will display a short description of the functions that match the specified pattern. Consider the below output:

Whatis command in Linux

Disable trimmed output

By default, the Linux terminal trims the output to the terminal width to avoid the ugly results. But we can avoid trimming the output by using the "-l or -long" option. To display the output without any trimming, execute the command as follows:

The above command will display the complete description of the ssh-import-id. Consider the below output:

Whatis command in Linux

The above command is displaying the complete output of the specified command.

To see the difference between trimmed and not trimmed output, execute the command without the '-l' option:

consider the below output:

Whatis command in Linux

The above command is displaying the trimmed output of the specified command.

Access other OS manual page

If we have the right to access to any other operating system's manual page, we can access them by using the '-m' option. For example, if we want to search the OS2's manual pages, we will execute the command as follows: whatis -m OS2 rmdir

The above command will let us access the rmdir command's short description from the OS2. Consider the below output:

Whatis command in Linux

Display the usage of whatis command

The '--usage' option displays the short information about the whatis command. It displays a short description and exits. Execute the below command:

The above command will print a short message about usage. Consider the below output:

Whatis command in Linux

Display the version of whatis command

To display the version of whatis command, execute it with the '-V' option. Consider the below command:

It will display the version of whatis command. Consider the below output:

Whatis command in Linux

Getting Help

If you stuck anywhere during the use of the command, you could get help from your terminal by executing the '-help' option with the command.

To display the help, execute the command as follows:

the above command will display the list of options that can be used with the whatis command with their description. Consider the below output:

Whatis command in Linux

As from the above output, we can see that different options are listed with their usage.


Next TopicLinux Error Codes





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA