For any Linux enthusiast, system administrator, or software developer working in a Unix-like environment, mastering command-line tools is essential. Among the many tools available, which, whereis, and whatis often come up when you’re trying to locate or understand other commands or executables. While they can sound similar and often get used interchangeably by beginners, these commands serve very different purposes.
This article demystifies these three commands, showing you exactly when to use each, and why they exist to begin with. Whether you’re new to Linux or a seasoned terminal navigator looking to clarify some confusion, this guide will shed light on these important tools.
What Do These Commands Really Do?
Let’s start with a quick comparative rundown of each command:
- which – Shows the location of executables in your PATH
- whereis – Locates the binary, source, and manual files of a command
- whatis – Gives a one-line description of a command from the manual
The ‘which’ Command
The which command is often the first tool people reach for when they want to know where an executable resides on the system. It searches the directories listed in your PATH environment variable and returns the location of the matching executable file.
Syntax:
which [command]
Example:
which python3
This might return something like:
/usr/bin/python3
When to use it:
- To verify that a command exists in your PATH
- To see which version of a command will be executed when multiple versions are available
- To help troubleshoot path issues or unexpected command behavior
Limitation: which only checks the commands in your PATH, and it does not look for manual pages or source code files.

The ‘whereis’ Command
This command goes much deeper than which. The whereis command searches for the binary, source, and manual pages related to a given command. It accomplishes this by looking in standard directories, rather than just following your PATH.
Syntax:
whereis [command]
Example:
whereis ls
This might return:
ls: /bin/ls /usr/share/man/man1/ls.1.gz
When to use it:
- When you want more information than just where the binary is
- To find the man pages and source files alongside binaries
- Useful for program troubleshooting or auditing systems
Bonus Tip: The whereis command is quite fast because it uses a pre-built file system index rather than combing through directories manually. However, this also means it may overlook files in unusual locations.
The ‘whatis’ Command
The whatis command is like the elevator pitch of Linux commands. Instead of telling you where a program lives, it explains what the program does — in one concise sentence. It extracts this summary from the man pages using a database built by the makewhatis utility (which is automatically run on many systems).
Syntax:
whatis [command]
Example:
whatis tar
This might return:
tar (1) - an archiving utility
When to use it:
- If you’re not sure what a command does
- Before running an unknown or unfamiliar command
- Useful for beginners who want a quick overview
Limitation: Some newer or custom-built commands may not have entries in the whatis database unless it’s updated regularly.

Comparison Table: which vs whereis vs whatis
Command | Purpose | Searches | Output Type |
---|---|---|---|
which | Finds executables in the PATH | PATH environment variable | Executable path(s) |
whereis | Finds binaries, source & man files | Standard system directories | Multiple path references |
whatis | Gives a brief command description | Man page database | Text summary |
Practical Use Cases
System Troubleshooting
You’re troubleshooting a broken shell script, and you’re unsure which version of python it uses. Running which python
tells you the exact location it’s sourced from, helping you diagnose environment inconsistencies.
Learning New Tools
Suppose a colleague tells you to use the htop
utility. You’re not sure what it is. Running whatis htop
gives you a 1-line description: “interactive process viewer.” You’ve got your answer in seconds, and if you’re intrigued, just follow it up with man htop
.
Auditing and Maintenance
Getting ready for system maintenance? Run whereis sshd
to see where the SSH daemon executable and configuration files live, so you can back things up or modify the settings safely.
Tips for Mastery
- Use
type
to see how a command is interpreted by your shell. It complements which in some cases. - Update your whatis database regularly with
sudo mandb
to ensure accurate descriptions. - Combine these tools for a full picture of any command: try
which gcc
,whereis gcc
, andwhatis gcc
in sequence.
Conclusion: The Right Tool for the Right Job
Although they may seem synonymous at first glance, which, whereis, and whatis each provide distinct and valuable insights into the Linux environment. Knowing when and how to use these tools can greatly enhance your command-line proficiency and confidence.
Use which to locate executables in your current environment. Leverage whereis when you want to dig deeper. And call on whatis when a quick explanation is all you need.
Mastering these commands may not require memorizing a huge cheat sheet, but understanding their roles will elevate your workflow and help you navigate Linux like a pro.