whereis – Find binary programs, code and other related file paths

The whereis command is a Linux utility that is used to locate the binary programs, source code, and manual pages for a given command. It searches for the specified command in a set of standard directories and returns the paths to the binary executable, source code, and manual page files.

Overview

The syntax for the whereis command is as follows:

whereis [options] command

Where command is the name of the command you want to search for.

For example, to find the location of the ls command, you would run the following command:

whereis ls

This would return the following output:

ls: /bin/ls /usr/share/man/man1/ls.1.gz

The output shows that the ls command is located in the /bin directory, and its manual page is located in the /usr/share/man/man1 directory.

You can also search for multiple commands at once by specifying them as arguments to the whereis command, like this:

whereis ls pwd

This would return the following output:

ls: /bin/ls /usr/share/man/man1/ls.1.gz
pwd: /bin/pwd /usr/share/man/man1/pwd.1.gz

The output shows the locations of the ls and pwd commands, as well as their respective manual pages.

Options

The following options are available for the whereis command:

Option Description
-b Search only for the binary executable file.
-m Search only for the manual page file.
-s Search only for the source code file.
-B Specify the directories to search for the binary executable file.
-M Specify the directories to search for the manual page file.
-S Specify the directories to search for the source code file.

Troubleshooting tips

If the whereis command does not return any results, it may be because the command you are searching for is not installed on your system. In this case, you can use the apt-get or yum command to install the missing package.

If the whereis command returns unexpected results, you can use the -B, -M, and -S options to specify the directories to search for the binary executable, manual page, and source code files, respectively.

Notes

  • The whereis command only searches for files in standard system directories, so it may not find files that are installed in non-standard locations.
  • The whereis command does not search for shared libraries or configuration files associated with a command. For this, you can use the which or locate commands.