UNIX / Linux whereis Command Examples

What is whereis ?
3 whereis examples
Syntax and Options
Related Commands

What is whereis ?

Whereis command is used to find out where the binary, source, and man page files for a command is located.

3 whereis Examples

Find whereis a UNIX command

When you want to find out where a specific Unix command exists (for example, where does ls command exists?), you can execute the following command.

$ whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz

Find whereis a UNIX command executable is located

When you want to know only where the executable for a specific command is available, use -b option. This is more handy, and you are most likely be using whereis command to find out the location of only executables.

$ whereis -b ls
ls: /bin/ls 

Change the search location of whereis command

When you want to search an executable from a path other than the whereis default path, you can use -B option and give path as argument to it.

$ whereis -u -B /tmp -f lsmk
lsmk: /tmp/lsmk

This searches for the executable lsmk in the /tmp directory, and displays it, if it is available.

Syntax and Options

Short Option Option Description
-b Search only for binaries
-m Search only for manual sections
-s Search only for sources
-u Search for unusual entries. A file is said to be unusual if it does not have one entry of each requested type. Thus ‘whereis -m -u’ asks for those files in the current directory which have no documentation
-B Change or otherwise limit the places where whereis searches for binaries
-M Change or otherwise limit the places where whereis searches for manual sections
-S Change or otherwise limit the places where whereis searches for sources
-f Terminate the last directory list and signals the start of file names, and must be used when any of the -B, -M, or -S options are used


Related Commands

locate