Linux Command Reference ยท Viewing and Searching Files
Linux whereis command
Reference for the Linux whereis command: locate the binary, source and manual page of a program in standard system directories, and limit the search with -b, -m and -s.
whereis looks for three things for each name you give it: the binary, the source and the manual page. Instead of searching your PATH, it checks a fixed list of standard system directories such as /bin, /usr/bin, /usr/share/man and /usr/src.
That makes it a quick way to see all the places a program has left files. It is less flexible than find and less precise than which, but needs no database.
whereis [OPTION]... NAME...
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
whereis [-bmsu] [-BMS DIR... -f] NAME...
| Option | Description |
|---|---|
-b |
Search for binaries only. |
-m |
Search for manual pages only. |
-s |
Search for sources only. |
-u |
List only names that are missing one of the requested kinds ("unusual" entries). |
-B DIR... |
Replace the default binary search directories; end the list with -f. |
-M DIR... |
Replace the manual search directories; end with -f. |
-S DIR... |
Replace the source search directories; end with -f. |
-l |
List the directories that are searched by default. |
Returns: 0 on success, also when nothing was found (the line then has only the name and a colon); non-zero on invalid usage.
Usage notes
- Output format is
name: path1 path2 .... A name with no matches prints justname:. - No PATH search. A program installed in
~/binor/opt/tool/binis invisible unless it is in the standard directories. Usewhichorcommand -vfor what your shell would run. - Symlinks are reported as separate entries. On a system with merged
/usr, you may see both/bin/lsand/usr/bin/ls. - Manual pages appear only if the man page package is installed. Minimal containers often have none, so
whereis -mreturns nothing there. - Where it comes from.
whereisis part of util-linux on Linux; BSD systems have a different implementation with different options. - Typical use: find the man page file for a command (
whereis -m crontab) or check whether source files are available. - Not recursive. It checks listed directories (and one level of subdirectories for some), not an entire tree.
- For scripts, prefer
command -v. The output ofwhereisis meant for people.
Related
which,type,find,locate- Lessons: Getting Help, Filesystem Layout