Whereis Command in Linux
3 min read
whereis is a command-line utility that allows you to find the location of the binary, source, and manual page files for a given command.
In this article, we will show you how to use the Linux
How to Use the
The syntax for the
whereis command is as follows:
whereis [OPTIONS] FILE_NAME...
When used without any options
whereis search the binary, source and manual files for the command specified as an argument.
whereis searches for the command's files in the hard-coded paths and directories listed in the environment variables. Use the
-l option to find the directories where the
whereis command search for.
For example, to get information about the
bash command, you would type the following:
bash: /bin/bash /etc/bash.bashrc /usr/share/man/man1/bash.1.gz
In the output above
bash: is the command for which you want to get information,
/bin/bash is the path to the binary file,
/etc/bash.bashrc is the source file, and
/usr/share/man/man1/bash.1.gz is the man page.
If the command you are searching for doesn't exist,
whereis will print only the command name.
You can also provide more than one arguments to the
whereis netcat uptime
netcat: /bin/netcat /usr/share/man/man1/netcat.1.gz uptime: /usr/bin/uptime /usr/share/man/man1/uptime.1.gz
To search only for the command binaries use the
For example, to find the location of the
ping command, you would type the following:
whereis -p ping
To search only for the source files, use the
whereis -s command
If the source files exist, the
whereis will print their locations.
-m option allows you to search only for man files:
whereis -m command
To limit the locations where
whereis searches for binaries use the
-B options, for manuals the
-M option, and
-S for sources. Each option accepts a list of absolute paths to directories separated by space. The directory list must be terminated by the
-f option that indicates the start of the filenames.
For example, to search for the
cp binary in the
/bin directory you would type:
whereis -b -B /bin -f cp
-u option tells
whereis to search for unusual entries. Files that do not have exactly one entry of each requested type (binary, manual and source) are considered to be unusual files (commands).
For example, to search for all binaries in the
/bin directory that doesn't have manual pages or have more than one documentation you would type:
whereis -m -u *
The wildcard character (
*) after the
-f option means all files in the current working directory (
whereis utility is used to locate the binary, source, and manual files for a given command.
If you have any questions or feedback, please leave a comment below.