Introduction
The whereis command is a simple but powerful tool available in most Linux distributions that allows you to quickly locate binary files, source code and manual (man) pages associated with a given program. Unlike other utilities such as find or locate, whereis is looking for a predefined set of system directories, which makes it very fast and suitable for daily management and development tasks. In this article we will see what is whereis, how its syntax works, what options it offers and some practical examples to make the most of it.
What is the command whereis?
whereis is part of the util-linux package and is responsible for searching the standard routes where the system keeps executable (/ bin, / sbin, / usr / sbin, etc.), libraries, source code and manuals. Your main objective is to provide an immediate response when we need to know where a command is installed or where to find your documentation, without having to go through the entire file system. This makes it a light alternative to find when no exhaustive search is required.
Basic syntax
The syntax of whereis is very simple:
whereis [options]
If no options are specified, whereis will display by default the location of the binary, the source code (if any) and the manual page. For example:
whereis ls
will produce something like:
ls: / usr / bin / ls / usr / share / man / man1 / ls.1.gz
Most commonly used options
- -b: Search only binaries.
- -m: Search only manual pages.
- -s: Search only source code.
- -u: Search for entries that do not have one of the requested types (useful for finding anomalies).
- - B: Change the binary search route.
- - M: Change the manual search route.
- - S: Change the source code search route.
These options can be combined as needed. For example,whereis -b gccshow only the location of the gcc binary.
Practical examples
- Check the installation of a program:
whereis nginxcan return/usr/sbin/nginxand its manual, confirming that the server is present. - Locate only the manual:
whereis -m python3show the route of the python3 manual page, useful when you want to consult the documentation quickly without opening the help terminal. - Search source code:
whereis -s bashcan return/usr/src/bash-5.1/if the sources are installed. - Detect missing files:
whereis -u comandomay help to identify if any of the three components (binary, source, manual) are missing in a partial installation.
Limitations and alternatives
Although whereis is fast, he has certain limitations. Your search is restricted to the predefined directories; if a binary is in a non-standard location (e.g. in / opt or in the user's home directory), you will not find it. In such cases, recourse tofindorlocate, who travel the entire file system or a regularly updated database. In addition, whereis does not track symbolic links by default, although it follows the links that appear on its search routes.
Conclusion
The Whereis command is an essential tool for any Linux user or administrator who needs to quickly locate binaries, manuals and source code. Its simple syntax and filtering options make it ideal for quick verifications and for administration scripts. Knowing its functioning and limits allows it to be effectively combined with other utilities such as find and locate, ensuring that the right information is available to the hand.


