whereis Command

The whereis command in Linux is used to locate the binary, source, and manual page files for a specified command. It searches a fixed set of standard locations for the requested program, making it a quick way to find where a command's components are installed on the system.

Syntax

whereis [options] [-bmsu] [-BMS directory... -f] name...

Description

whereis locates the binary, source, and manual page files for the specified program names. The supplied names are first stripped of leading path components and any (single) trailing extension of the form .ext, e.g. .c, .f, .man. Then it attempts to locate the desired program in a list of standard Linux directories.

Common uses include:

  • Finding the executable path of a command
  • Locating the source code for a command
  • Discovering the manual page location for a command
  • Verifying if a command is installed and where

Common Options

Option Description
-b Search only for binaries.
-m Search only for manual sections.
-s Search only for sources.
-u Search for unusual entries (those that do not have one entry of each requested type).
-B directory... Limit the places where whereis will look for binaries.
-M directory... Limit the places where whereis will look for man pages.
-S directory... Limit the places where whereis will look for source files.

Examples

Locate all files for a command

whereis ls

Locates the binary, source, and manual page for the 'ls' command.

Locate only the binary for a command

whereis -b bash

Finds the executable path for the 'bash' shell.

Locate only the manual page for a command

whereis -m grep

Finds the manual page location for the 'grep' command.

Locate only the source for a command

whereis -s find

Finds the source code location for the 'find' command.

Locate unusual entries (missing components)

whereis -u -m -s * | grep -v '\.'

Finds commands that do not have a manual page or source file.

See also