Search

The whereis command

Looks up the binary, source code and manual pages of a program in the standard system paths. It is faster than find because it does not scan the whole disk. It is useful to quickly check whether a program is installed and where.

Syntax

whereis [opciones] nombre...Try it in the terminal →

Most useful options

-bSearches only binaries and executables
-mSearches only manual pages
-sSearches only source code
-B RUTA... -fAdds paths where to look for binaries. The path list ends with -f. There are -M and -S for manuals and sources

Copy-ready examples

$ whereis lsshows the binary and the manual page of ls. The paths are separated by spaces.

Example output

ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz
$ whereis -b gcconly the gcc executable, without the manual.

Example output

gcc: /usr/bin/gcc
$ whereis -m gitonly the git manual page, useful to know whether it is installed.

Example output

git: /usr/share/man/man1/git.1.gz

You can try them in the browser terminal: it does not touch your computer.

Common errors

MessageCauseFix
No error messageIt finds nothing. It returns only the name followed by a colon, with no paths.Use which or type, or search with find in the folders you care about.
No error messageIt only looks in standard paths. A program in /opt or in your home folder does not appear unless you give the path.Add the path with -B, or use which if the program is in PATH.
bash: whereis: command not foundThe command is not installed. It usually comes with the util-linux package.Install it with your distribution package manager.

Typical mistakes

  • It only finds programs installed in standard paths. A binary copied by hand into another folder does not show up.
  • It can show several paths and does not say which one runs first. Use which or type for that.
  • If several versions are installed, it shows all of them with no order of preference.

Differences from similar commands

  • which: searches only PATH and returns the executable that would run. whereis also looks at manuals and sources.
  • type: recognizes aliases, functions and shell builtins. whereis knows nothing about the shell.
  • find: walks the directory tree you indicate, with filters. It is slower but finds any file.

Related commands

FAQ

What is the difference between whereis and which?

which searches only PATH and returns the one that would run. whereis also searches manuals and sources in fixed paths.

Why doesn't whereis find my program?

Because it is outside the standard paths. Add its folder with -B, ending the list with -f, or type the full path.

How do I search only the manual of a command?

With whereis -m name, which shows only the paths of the manual pages.

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course