whereis
Locate binary, source, and manual files
TLDR
Locate binary, source and man pages for SSH
Locate binary and man pages for ls
Locate source of gcc and man pages for Git
Locate binaries for gcc in /usr/bin/ only
Locate unusual binaries (those that have more or less than one binary on the system)
Locate binaries that have unusual manual entries (binaries that have more or less than one manual installed)
SYNOPSIS
whereis [options] name ...
PARAMETERS
-b
Search only for binaries.
-m
Search only for manual sections.
-s
Search only for sources.
-u
Search for unusual entries. A file is said to be unusual if it does not have at least one entry of each requested type. Thus, 'whereis -m -u *' asks for those files in the current directory which have no manual page.
-B
Search for binaries only in the given directories.
-M
Search for manuals only in the given directories.
-S
Search for sources only in the given directories.
-f
Terminate the last directory list and signals the start of filenames.
DESCRIPTION
The whereis command is a utility on Unix-like operating systems used to locate the binary, source, and manual page files for a specified command. It searches a pre-defined set of standard locations. Unlike locate or find, whereis uses a database of known file locations. This pre-defined locations include standard Linux directories like /usr/bin, /usr/sbin, /usr/share/man, and their local counterparts.
The command's primary function is to quickly pinpoint the executable file, its source code (if available), and its corresponding man page documentation. It is helpful for system administrators and developers who need to understand the location and composition of system utilities. The output consists of the command name followed by the paths of the located files. The command does not perform a comprehensive system-wide search, but offers a quick and effective method for finding files in standard locations.
CAVEATS
whereis relies on a database that may not always be up-to-date. Use updatedb (or its system equivalent) to refresh the database if necessary. Results might be inaccurate if the database is stale.
EXIT STATUS
The whereis command returns an exit status of 0 if the command completed successfully, and a non-zero exit status if an error occurred.
DATABASE LOCATION
The exact location of the database used by whereis is system-dependent. It is often located in /var/lib/locate/ or /usr/share/locate/.
HISTORY
whereis is a standard Unix utility that has been around for a long time. It's designed to be a relatively quick and simple method for locating standard components of a program. Its inclusion in the POSIX standard has ensured its continued availability across various Unix-like systems.