Locating Binary Files with whereis
The whereis
command is a powerful tool for quickly locating binary files on a Linux system. By using this command, you can easily find the location of executable files, source code, and manual pages for a given command or program.
Locating Executable Binary Files
To locate the executable binary file for a specific command, you can use the whereis
command with the command name as an argument. For example, to find the location of the ls
command, you would run:
whereis ls
This will output the path to the binary file, which in this case would be something like /usr/bin/ls
.
Locating Source Code Files
In addition to the binary file, the whereis
command can also locate the source code files for a given program. If the source code is available on your system, the output of the whereis
command will include the path to the source files.
For example, to find the location of the source code for the gcc
(GNU Compiler Collection) command, you would run:
whereis gcc
The output might look something like this:
gcc: /usr/bin/gcc /usr/lib/gcc /usr/include/gcc /usr/share/gcc-10 /usr/share/man/man1/gcc.1.gz
In this case, the source code files are likely located in the /usr/lib/gcc
and /usr/include/gcc
directories.
Locating Manual Pages
The whereis
command can also help you find the location of the manual pages (man pages) for a given command or program. The manual page location will be included in the output of the whereis
command.
For example, to find the location of the manual page for the ls
command, you would run:
whereis ls
The output might look like this:
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz
In this case, the manual page for the ls
command is located in the /usr/share/man/man1/ls.1.gz
file.
By using the whereis
command, you can quickly and easily locate the necessary files for a given program or command, which is particularly useful when working with binary files and system-level utilities in a Linux environment.