whereis is a command-line utility that locates the binary, source, and manual page files for a given command. It helps you find the location of a command's executable file, source code files, and associated documentation. The "whereis" command only searches for commands installed on the system and uses a prebuilt database, so it may not account for commands or files not indexed in that database.
In this tutorial, we will demonstrate how to use the Linux
whereis command. We will also address a few FAQs on whereis Command in Linux.
How to Use the
The syntax for
whereis is as follows:
whereis [OPTIONS] FILE_NAME...
Whereis searches the binary, source, and manual files for the command specified as an argument when used without any options.
whereis looks for the command's files in the environment variables hard-coded paths and directories. To find the directories that the
whereis command searches for, use the
whereis -l 1
For example, to learn more about the bash command, type the following:
bash: /bin/bash /etc/bash.bashrc /usr/share/man/man1/bash.1.gz
The command for which you want information is
bash:, the path to the binary file is
/bin/bash, the source file is
/etc/bash.bashrc, and the man page is
If the command you're looking for does not exist,
whereis will only print the command name.
You can also use the
whereis command with multiple arguments:
whereis netcat uptime
Both netcat and uptime commands will be listed in the output:
netcat: /bin/netcat /usr/share/man/man1/netcat.1.gz
uptime: /usr/bin/uptime /usr/share/man/man1/uptime.1.gz
-b option to only look for command binaries.
To find the location of the ping command, for example, type the following:
whereis -b ping
-s option to search only for source files.
whereis -s command
If the source files are present, the
whereis command will display their locations.
-m option restricts the search to only man files:
whereis -m command
-B option to limit the locations where
whereis searches for binaries,
-M for manuals, and
-S for sources. Each option accepts a space-separated list of absolute paths to directories. The
-f option, which indicates the beginning of the filenames, must be used to end the directory list.
For example, to look for the cp binary in the
/bin directory, type:
whereis -b -B /bin -f cp
-u option specifies
whereis to look for unusual entries. Unusual files are those that do not have exactly one entry of each requested type (binary, manual, and source) (commands).
For example, to find all binaries in the
/bin directory that lack manual pages or have more than one documentation, type:
whereis -m -u *
-f option, the wildcard character
(*) denotes all files in the current working directory
FAQs to whereis command in Linux
How do I use the "whereis" command?
To use the "whereis" command, simply type "whereis" followed by the name of the command you want to locate files for.
What files does the "whereis" command locate?
The "whereis" command locates the binary (executable), source code, and manual page files associated with a command.
Can the "whereis" command find all commands installed on my system?
No, the "whereis" command can only find commands that are installed and indexed in its database.
How can I limit the search to find only the binary file or the source file using "whereis"?
You can add options to the "whereis" command. For example, "-b" limits the search to binary files, and "-s" limits it to source files.
Can "whereis" locate multiple files associated with a command?
Yes, "whereis" can locate multiple files if they exist. It will display all the locations where the files are found.
Does the "whereis" command search in specific directories only?
The "whereis" command searches in default directories where binaries, sources, and manual pages are typically installed. It does not search user-defined directories.
Can the "whereis" command be used with scripts or aliases?
No, the "whereis" command is primarily designed to locate files associated with individual commands, not scripts or aliases.
whereis utility is used to locate a command's binary, source, and manual files.
If you have any queries, please leave a comment below and we’ll be happy to respond to them.