Discover how to instantly find any command on your system without endless searching!
Why which and whereis for commands in Linux CLI? - Purpose & Use Cases
Imagine you want to run a program on your computer, but you don't know where it is installed or which version will run if you type its name. You try typing the command, but sometimes it doesn't work or runs a different program than you expected.
Manually searching for a program's location means digging through folders one by one. This is slow and confusing, especially when many programs have similar names or multiple versions exist. You might run the wrong program by mistake, causing errors or wasted time.
The which and whereis commands quickly tell you where a program lives on your system. which shows the exact program that will run when you type its name, while whereis finds all related files like executables, source code, and manuals. This saves time and avoids confusion.
ls /usr/bin | grep program_name find / -name program_name
which program_name whereis program_name
You can instantly find and verify the exact program you want to run, making your work faster and more reliable.
When installing new software, you can use which to check if the command is ready to use, or whereis to find its documentation and binaries without guessing.
which shows the command that will run from your PATH.
whereis locates all files related to a command.
Both save time and reduce errors when working with commands.