whereis Command in Linux: Find Binary, Source, and Man Pages

By 

Updated on

4 min read

whereis Command

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.

This article explains how to use the Linux whereis command.

How to Use the whereis Command

The syntax for the whereis command is as follows:

txt
whereis [OPTIONS] FILE_NAME...

When used without any options, whereis searches for the binary, source, and manual files for the command specified as an argument.

By default, whereis searches for the command’s files in hard-coded paths and directories listed in the environment variables . Use the -l option to print the directories that whereis searches:

Terminal
whereis -l

For example, to get information about the bash command, you would type the following:

Terminal
whereis bash
output
bash: /bin/bash /etc/bash.bashrc /usr/share/man/man1/bash.1.gz

In the output above, bash: is the command name, /bin/bash is the path to the binary, /etc/bash.bashrc is a file found in the source search paths (most commands will not have C source files installed), and /usr/share/man/man1/bash.1.gz is the man page.

If the command you are searching for does not exist, whereis will print only the command name.

You can also provide more than one argument to the whereis command:

Terminal
whereis netcat uptime

The output will include information about both netcat and uptime commands:

output
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 -b option.

For example, to find the location of the ping command, you would type the following:

Terminal
whereis -b ping
output
ping: /bin/ping

When searching only for the location of the command binary, prefer using the which or type commands.

To search only for the source files, use the -s option.

Terminal
whereis -s command

If the source files exist, whereis will print their locations.

The -m option allows you to search only for man files:

Terminal
whereis -m command

To limit the locations where whereis searches for binaries use the -B option, 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:

Terminal
whereis -b -B /bin -f cp
output
cp: /bin/cp

The -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 find all commands in /bin that do not have manual pages, change into that directory and run:

Terminal
cd /bin
whereis -m -u *

The * expands to all filenames in the current working directory , so whereis checks each one and reports those without a matching man page.

Quick Reference

OptionDescription
whereis commandFind binary, source, and man page for a command
whereis -b commandSearch only for the binary
whereis -m commandSearch only for the man page
whereis -s commandSearch only for source files
whereis -lList directories searched by whereis
whereis -B /dir -f commandLimit binary search to a specific directory
whereis -M /dir -f commandLimit man page search to a specific directory
whereis -u *Find commands missing binary, source, or man page
whereis cmd1 cmd2Query multiple commands at once

FAQ

What is the difference between whereis and which?
which returns only the path to the executable that would be run in the current shell environment. whereis is broader: it also locates the man page and source files, and searches hard-coded system paths rather than just $PATH.

Why does whereis show no output for a command?
If whereis prints only the command name with no paths, it means no binary, source, or man page was found in the directories it searches. The command may not be installed, or its files may be in a non-standard location not covered by whereis.

How do I search only for a man page location?
Use the -m option: whereis -m command. This prints only the path to the manual page file.

Can whereis search multiple commands at once?
Yes. Pass multiple command names as arguments: whereis bash grep awk. Each result is printed on its own line.

Conclusion

The whereis command is a quick way to locate the binary, man page, and source files for any installed command. For finding only the executable path, the which or type commands are more focused alternatives.

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

Dejan Panovski

Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.

View author page