Skip to content

What is whereis Linux command?

The Linux whereis command is a useful utility for locating the binary, source, and man page files of a given command. It helps users quickly identify the location of executable files on their system.

whereis Syntax:

Terminal window
whereis [option] [parameter]

whereis Options:

OptionDescription
-bSearch only for binaries
-mSearch only for manual pages
-sSearch only for source code
-uSearch only for unusual entries (not binaries, manual pages, or source code)
-BSpecify the location of binary directories
-MSpecify the location of manual page directories
-SSpecify the location of source code directories

Parameters:

ParameterDescription
nameThe name of the file or command to search for

whereis Command Usage Examples:

Find the location of the ls command

Terminal window
whereis ls

Locates the binary, source code, and manual page files for the “ls” command.

Locate the location of the nano text editor

Terminal window
whereis nano

Returns the paths to where the binary, source, and manual pages for the “nano” text editor are stored.

Search for the location of the gcc compiler

Terminal window
whereis gcc

Shows the paths of the binary, source code, and manual pages related to the GNU Compiler Collection (gcc).

Check the location of the Python interpreter

Terminal window
whereis python

Displays the paths of the binary executable, source code, and manual pages for the Python programming language interpreter.

Find the path of the vi text editor

Terminal window
whereis vi

Identifies the locations of the binary executable, source code, and manual pages for the “vi” text editor.

How do I use whereis in Linux?

To use the whereis command in bash, execute the following command:

Terminal window
whereis ls

How can I search for multiple commands using whereis?

To search for multiple commands, you can specify the command names separated by spaces in the whereis command like this:

Terminal window
whereis ls cat mkdir

How can I search for only binaries using whereis?

To search for only binary files and not include source and manual pages, you can use the -b option with the whereis command:

Terminal window
whereis -b ls

How can I list only the source files using whereis?

To list only the source files related to a command, you can use the -s option with whereis like this:

Terminal window
whereis -s cat

How can I display the paths in which the found files are located using whereis?

To display the paths where the found files are located, you can use the -l option with whereis like this:

Terminal window
whereis -l grep

To update the cache used by whereis, you can use the updatedb command to update the file database like this:

Terminal window
sudo updatedb

How can I ignore specific directories when searching with whereis?

To ignore specific directories during the search, you can use the -f option followed by the directory you want to exclude like this:

Terminal window
whereis -f /usr/bin ls

Applications of the whereis command

  1. Locating binary executable files
  2. Finding the location of source code files
  3. Determining the location of manual pages for commands