Linux / Unix whereis Command Examples

whereis command

I am a new Linux and Unix-like system command line user. How do I find and locate the binary, source, and manual page files for a given command?

You need to use the whereiscommand to find the source, binary, and manuals sections for specified commands or files.

whereis command details
DescriptionLocating command or program
Root privilegesNo
Est. reading time10m
Table of contents
A binary is nothing but an executable from of a command such as ls or program such as Gimp. Use this command to find out:

  1. The location of a binary file.
  2. And the location of source code.
  3. Finally, the location of man page.


Find the binary, source code and man page for specified program or command.


The basic syntax is as follows:

whereis command
whereis program
whereis [options] program
whereis -BMS directory  -f command

whereis command examples

To find out the location of the executable, source code and man page for the date command, type:
$ whereis date
Sample outputs:

Animated gif 01: whereis command running on my Debian based server

Animated gif 01: whereis command running on my Debian based server

How do I only search for binary files?

Try passing the -b option as follows:
$ whereis -b date

How do I only search for manual sections files?

Use the -m option as follows:
$ whereis -m date

How do I only search for source code files?

Pass the -s option as follows:
$ whereis -s date
whereis command examples for Linux and Unix

How do I only Search for unusual entries?

A file is said to be unusual if it does not have one entry of each requested type. Thus the following example, asks for those files in the current directory which have no documentation:
$ whereis -m -u *

How can I limit the searches for binaries to specific directories?

You can pass the following option to limit limit the places where whereis searches for files:

  • -B /path/to/dir : Limit the places where whereis searches for binaries.
  • -M /path/to/dir : Limit the places where whereis searches for manual sections.
  • -S /path/to/dir : Limit the places where whereis searches for sources.

You must pass the -f option when any of the -B, -M, or -S options are used. The -f option terminate the last directory list and signals the start of file names. In this example, limit search for binary files in /bin/ directory only for ls and gcc commands:
$ whereis -B /bin -f ls gcc
Sample outputs:

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

There is no output for the gcc command since it is located in /usr/bin/ directory. To find all of the files in the /sbin/ directory that either are not documented in the /usr/man/man8 directory or do not have source in the /root/src directory, enter:
# cd /sbin
# whereis -u -M /usr/man/man8/ -S /root/src/ -f *

whereis command options

From the whereis(1) command man page:

Option Meaning
-f Define search scope.
-b Search only binaries.
-B Define binaries lookup path.
-m Search only manual paths.
-M Define man lookup path.
-s Search only sources path.
-S Define sources lookup path.
-u Search from unusual enties.
-V Output version information and exit.
-h Display this help and exit.
See also
  • whereis(1) Linux/Unix command man page or read it online here.


This page explained whereis command with examples for Linux and Unix users.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 5 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
5 comments… add one
  • Ivan Feb 19, 2014 @ 11:19

    Well done, guys ;)!

  • Jeremy Boden Feb 19, 2014 @ 12:38

    Why not use the locate command for a list of files where you only know part of the name and nothing else?

  • jameslee Feb 19, 2014 @ 15:21

    Thanks.its useful

  • Jose Damian Bazaga Ruiz Mar 9, 2014 @ 20:54

    Helpful. Thank you for sharing this useful information about this command.

  • aref ghobadi Aug 15, 2015 @ 15:04

    thanks a lot

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum