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 How to find files on Linux There are many options you can use to find files on Linux, including searching by file name (or partial name), age, owner, group, size, type and inode number. By Sandra Henry Stocker Jun 24, 2024 8 mins Linux opinion Linux in your car: Red Hat’s milestone collaboration with exida With contributions from Red Hat and critical collaborators, the safety and security of automotive vehicles has reached a new level of reliability. By Sandra Henry Stocker Jun 17, 2024 5 mins Linux how-to How to print from the Linux command line: double-sided, landscape and more There's a lot more to printing from the Linux command line than the lp command. Check out some of the many available options. By Sandra Henry Stocker Jun 11, 2024 6 mins Linux how-to Converting between uppercase and lowercase on the Linux command line Converting text between uppercase and lowercase can be very tedious, especially when you want to avoid inadvertent misspellings. Fortunately, Linux provides a handful of commands that can make the job very easy. By Sandra Henry Stocker Jun 07, 2024 5 mins Linux PODCASTS VIDEOS RESOURCES EVENTS NEWSLETTERS Newsletter Promo Module Test Description for newsletter promo module. Please enter a valid email address Subscribe