Locating Binary Files with the whereis
Command
In the Linux file system, binary files can be scattered across various directories, making it challenging to quickly locate them. Fortunately, the whereis
command is a powerful tool that can help you find the location of binary files on your system.
Using the whereis
Command
The whereis
command is a Linux system utility that searches for a specified program in a predefined set of directories, including the system's binary directories, manual page directories, and source code directories. The basic syntax for the whereis
command is:
whereis [options] [filename]
Here are some common options for the whereis
command:
-b
: Searches only for binary files.
-m
: Searches only for manual pages.
-s
: Searches only for source files.
Locating Binary Files with whereis
Let's explore how to use the whereis
command to locate binary files on an Ubuntu 22.04 system. For example, to find the location of the ls
command, you can run:
$ whereis ls
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz
The output shows that the ls
binary file is located in the /usr/bin/ls
directory, and the corresponding manual page is located in /usr/share/man/man1/ls.1.gz
.
You can also use the whereis
command to search for other system utilities, such as git
or python3
:
$ whereis git
git: /usr/bin/git /usr/share/git /usr/share/man/man1/git.1.gz
$ whereis python3
python3: /usr/bin/python3 /usr/lib/python3.10 /usr/share/man/man1/python3.1.gz
The whereis
command is a valuable tool for quickly locating binary files on your Linux system, which can be especially useful when troubleshooting issues or trying to understand the file system structure.