📍 Command: whereis (Locate Binary, Source, and Manual Pages)
While which only tells you which executable will run, whereis is more comprehensive. It looks for the binary (the program), the source code, and the man pages (documentation) for a command in a standard set of Linux locations.
1. The "Why"
For an Arch Linux power user, whereis is the "developer's search."
- Find Documentation: Quickly see if a command has a manual page installed so you can learn its flags.
- Locate Source: If you are compiling tools or writing tutorials,
whereishelps you see if the source files are already on your system. - Verify Clean Installs: Check if multiple versions of a tool (like different Java versions or GCC) have left binaries in different directories like
/usr/binvs/usr/local/bin.
2. How it Works
whereis doesn't use your $PATH environment variable like which does. Instead, it searches a hardcoded list of standard system directories (like /bin, /sbin, /usr/lib, /usr/share/man, etc.).
3. Basic Syntax
whereis [COMMAND_NAME]
Example Output:
java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz
(This shows the executable, the library folder, and the manual page.)
4. Practical Examples for Your Workflow
A. Finding Only the Binary (-b)
If you just want the path to the executable file (similar to which but searching standard paths):
whereis -b python
B. Finding Only the Manual Page (-m)
Great for when you are writing your technical tutorials and need to check the official documentation:
whereis -m journalctl
C. Finding Only the Source (-s)
If you have installed the source for a package (common in Arch if using certain AUR packages or development headers):
whereis -s bash
D. Searching for Multiple Tools
You can check several commands at once to see their system footprint:
whereis java javac node
5. whereis vs. which vs. locate
| Command | Search Scope | Best Use Case |
|---|---|---|
which |
Only $PATH |
"What runs when I type this?" |
whereis |
System standard paths | "Where are the docs and binaries for this?" |
locate |
Entire disk (via database) | "I lost a file somewhere; find it." |
6. Pro-Tips
- Arch Linux Context: On Arch, because it is a "rolling release" and follows the File Hierarchy Standard strictly,
whereisis very reliable for finding man pages located in/usr/share/man. - The "Unusual" Search (
-u): This is a powerful flag that finds "unusual" entries—commands that do not have exactly one binary, one source, and one manual page in the expected spots. - Java Development: If you are configuring your environment ,
whereis javais the fastest way to find the/usr/share/javadirectory where many.jarlibraries are stored.
7. Summary Reference
| Goal | Command |
|---|---|
| Find all related files | whereis [cmd] |
| Find binary only | whereis -b [cmd] |
| Find manual pages only | whereis -m [cmd] |
| Search in custom paths | whereis -B /path/ -f [cmd] |