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 examine files on Linux Linux provides very useful options for viewing file attributes, such as owners and permissions, as well as file content. By Sandra Henry Stocker Oct 24, 2024 6 mins Linux how-to 8 easy ways to reuse commands on Linux Typing the same command again and again can become tiresome. Here are a number of ways you can make repeating commands – or repeating commands but with some changes – a lot easier than you might expect. By Sandra Henry-Stocker Oct 15, 2024 5 mins Linux news SUSE Edge upgrade targets Kubernetes and Linux at the edge SUSE Edge 3.1 includes a new stack validation framework and an image builder tool that are aimed at improving the scalability and manageability of complex Kubernetes and Linux edge-computing deployments. By Sean Michael Kerner Oct 15, 2024 6 mins Edge Computing Linux Network Management Software how-to Lesser-known xargs command is a versatile time saver Boost your Linux command line options and simplify your work with xargs, a handy tool for a number of data manipulation tasks. By Sandra Henry Stocker Oct 11, 2024 6 mins Linux PODCASTS VIDEOS RESOURCES EVENTS NEWSLETTERS Newsletter Promo Module Test Description for newsletter promo module. Please enter a valid email address Subscribe