‘whatis’ Linux Command: Quick Guide with Examples

The “whatis” command in Linux is a handy tool that quickly provides a one-line description of any command or file on your system. It’s a useful utility for both beginners and experienced users who want a brief summary of a command without having to dive deep into its manual pages.

1. What is the “whatis” Command?

The “whatis” command is part of the man-db package, which includes tools for browsing and searching man pages (manual pages). When you run the “whatis” command followed by another command or file name, it searches the manual page database and returns a brief description of that command. This helps you quickly understand what a command does without needing to read through the entire manual.

2. How to Use the “whatis” Command

Using the “whatis” command is straightforward. The basic syntax is:

whatis [command]

For example, if you want to know what the “ls” command does, you can type:

whatis ls

The output will be something like:

ls (1) - list directory contents

This tells you that “ls” is used to list the contents of a directory.

3. Examples of the “whatis” Command

Example 1: Understanding Basic Commands
If you’re unsure about the “grep” command, simply type:

whatis grep

The output might be:

grep (1) - print lines matching a pattern

This brief description tells you that “grep” is used for searching text based on patterns.

Example 2: Checking File Types
You can also use “whatis” to understand file types. For instance:

whatis /bin/bash

The output could be:

bash (1) - GNU Bourne-Again SHell

This tells you that “/bin/bash” is the GNU Bourne-Again Shell, which is the default command interpreter on many Linux systems.

4. Benefits of Using the “whatis” Command

  • Quick Reference: The “whatis” command provides a fast way to get a brief overview of a command’s function.
  • Saves Time: Instead of sifting through extensive man pages, you can get the gist of a command in seconds.
  • Helpful for Learning: New users can use “whatis” to familiarize themselves with the various commands available on Linux.

5. Limitations of the “whatis” Command

While “whatis” is useful, it only provides a one-line description. If you need detailed information about a command, including options and examples, you’ll still need to consult the full man pages using:

man [command]

For instance:

man ls

This will open the complete manual for the “ls” command.

6. Updating the “whatis” Database

Sometimes, the “whatis” database might not be up-to-date, especially after installing new software. To update the database, you can use the following command:

sudo mandb

Running this command will refresh the manual page database, ensuring that “whatis” has the latest information.

Leave a Comment