• United States
Unix Dweeb

Using whereis, whatis, and which to find out about commands on Linux

Apr 20, 20224 mins

The whereis, whatis and which commands can provide information on Linux commands, but in spite of names that appear related, they provide very different answers.

One large glowing question mark surrounded by many small question marks.
Credit: CarlosCastilla / Getty Images

When you’re trying to find your way around the Linux file system and want some information on specific commands, the whereis, whatis, and which commands can help. Each provides a different view of the command you’re asking about. In this post, I’ll compare these commands and explain what they tell us and what they don’t tell us.


The which command is the simplest of the three. When you use it to ask about a Linux command, it will run down your search path looking for executable files by the name you specify. These can be commands that are available on your system as well as scripts. As long as the files provide you with execute privilege, they fit the bill. Here are some examples:

$ which date
$ which init
$ which loop

The which command does nothing more than show the location of the file. It also stops as soon as it finds a match. The first location in your search path that contains an executable file by the name specified is the one you will see listed.

In general, which is used to display the location of a command so that you will know what executable you are running when you type the name of the command. Sometimes it’s important to verify that you’re not running a different command than the one you expect to run. A well-crafted search path should help ensure that you are running the expected command. In general, this means having the system directories like /usr/bin, /usr/sbin and /usr/local/bin precede your personal directory and personal bin directory.


The whereis command is more liberal in its approach to locating files. It will find the file you are looking for along with related commands. On the other hand, it only looks for the binary, source, and manual page files for a command. It doesn’t require that the files be executable, and it doesn’t follow your search path. It only looks in particular locations and, as you can see from the example below, one of these might be your bin directory.

Notice that the last two of the files shown in this whereis output are gzipped man pages that are unzipped when you use the man command to read them.

$ whereis date
date: /usr/bin/date /home/shs/bin/date /usr/share/man/man1/date.1.gz


The whatis command doesn’t look for files at all. Instead, it provides a brief explanation of Linux commands. It pulls the information from the related man pages. Here’s an example:

$ whatis date
date (1)             - print or set the system date and time
date (1p)            - write the date and time

In the command above, the whatis command is providing two very brief explanations of the date command. It pulls the first of these descriptions from the primary man page and the second from the man page stored in the 1p folder (/usr/share/man/man1p/date.1p.gz). If you want to view these man pages, you could use commands like these:

$ man date
$ man 1p date

Note that the NAME section in the related man pages include the brief descriptions shown above.

$ man date | head -4
DATE(1)                          User Commands                         DATE(1)

date - print or set the system date and time
$ man 1p date | head -10
DATE(1P)                   POSIX Programmer's Manual                  DATE(1P)

       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
       implementation of this interface may differ (consult the  corresponding
       Linux  manual page for details of Linux behavior), or the interface may
       not be implemented on Linux.

       date — write the date and time


The whereis, whatis and which commands can be helpful for ensuring you’re running the command you intend, finding commands and related files and giving you very succinct descriptions of what the commands can do for you.

Unix Dweeb

Sandra Henry-Stocker has been administering Unix systems for more than 30 years. She describes herself as "USL" (Unix as a second language) but remembers enough English to write books and buy groceries. She lives in the mountains in Virginia where, when not working with or writing about Unix, she's chasing the bears away from her bird feeders.

The opinions expressed in this blog are those of Sandra Henry-Stocker and do not necessarily represent those of IDG Communications, Inc., its parent, subsidiary or affiliated companies.

More from this author