LinuxCommandLibrary

whereis

Locate binary, source, and manual files

TLDR

Locate binary, source and man pages for SSH

$ whereis [ssh]
copy

Locate binary and man pages for ls
$ whereis -bm [ls]
copy

Locate source of gcc and man pages for Git
$ whereis -s [gcc] -m [git]
copy

Locate binaries for gcc in /usr/bin/ only
$ whereis -b -B [/usr/bin/] -f [gcc]
copy

Locate unusual binaries (those that have more or less than one binary on the system)
$ whereis -u *
copy

Locate binaries that have unusual manual entries (binaries that have more or less than one manual installed)
$ whereis -u -m *
copy

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.

SEE ALSO

locate(1), which(1), find(1)

Copied to clipboard