Locating Binaries, Source Files, and Manual Pages with whereis
The whereis
command in Linux is not only useful for finding the location of a specific command or program, but it can also be used to locate the associated binary, source files, and manual pages for that software.
Let's explore how the whereis
command can be used to locate these different file types:
Locating Binaries
To find the location of the binary file for a command or program, you can simply use the whereis
command followed by the name of the software. For example, to locate the binary for the gcc
compiler on an Ubuntu 22.04 system, you would run:
whereis gcc
This would output the location of the gcc
binary, which is typically /usr/bin/gcc
.
Locating Source Files
The whereis
command can also be used to find the location of the source files for a given command or program. To do this, you can use the -s
option with the whereis
command. For example, to locate the source files for the gcc
compiler, you would run:
whereis -s gcc
This would output the location of the gcc
source files, which are typically stored in the /usr/lib/gcc
directory.
Locating Manual Pages
In addition to binaries and source files, the whereis
command can also be used to find the location of the manual pages (man pages) for a command or program. To do this, you can use the -m
option with the whereis
command. For example, to locate the manual page for the gcc
compiler, you would run:
whereis -m gcc
This would output the location of the gcc
manual page, which is typically stored in the /usr/share/man/man1/gcc.1.gz
file.
By understanding how to use the whereis
command to locate binaries, source files, and manual pages, you can quickly and easily find the files you need when working with various commands and programs in your Linux environment.