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. 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. which 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 /usr/bin/date $ which init /usr/sbin/init $ which loop ~/bin/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. whereis 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 /usr/share/man/man1p/date.1p.gz whatis 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) NAME date - print or set the system date and time $ man 1p date | head -10 DATE(1P) POSIX Programmer's Manual DATE(1P) PROLOG 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. NAME date — write the date and time Wrap-Up 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. Related content how-to Compressing files using the zip command on Linux The zip command lets you compress files to preserve them or back them up, and you can require a password to extract the contents of a zip file. By Sandra Henry-Stocker May 13, 2024 4 mins Linux opinion NSA, FBI warn of email spoofing threat Email spoofing is acknowledged by experts as a very credible threat. By Sandra Henry-Stocker May 13, 2024 3 mins Linux how-to The logic of && and || on Linux These AND and OR equivalents can be used in scripts to determine next actions. By Sandra Henry-Stocker May 02, 2024 4 mins Linux how-to Using the apropos command on Linux By Sandra Henry-Stocker Apr 24, 2024 3 mins Linux PODCASTS VIDEOS RESOURCES EVENTS NEWSLETTERS Newsletter Promo Module Test Description for newsletter promo module. Please enter a valid email address Subscribe