Master Linux’s whereis Command: Fast File Location Explained
This guide explains how the Linux whereis command quickly locates executables, source files, and manual pages using a system database, details its options, compares it with find, and provides practical examples for searching the ls command.
The whereis command can only search for program names and looks for binary files (option -b), manual pages (option -m), and source code files (option -s). If no option is given, it returns all available information.
Compared with find, whereis is much faster because Linux maintains a database of all files; both whereis and the related locate command query this database instead of traversing the disk, resulting in higher efficiency.
The database is not updated in real time; by default it refreshes weekly, so whereis or locate may return paths to files that have been deleted or miss newly created files until the next update.
Command Format
whereis [options]... filenameCommand Function
The whereis command locates the executable, source code, and manual (help) files of a program within the file system. It can also search for source code, specify alternative search paths, and find unusual items.
Command Options
-b Locate binary (executable) files.
-m Locate manual (help) files.
-s Locate source code files.
-u Search for files other than binaries, sources, or manuals in the default paths.
-B Specify the search path for binaries.
-M Specify the search path for manual files.
-S Specify the search path for source files.
Find the location of the ls command and its manual
whereis ls
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gzShow the binary of ls
whereis -b ls
ls: /usr/bin/lsShow the manual of ls
whereis -m lsOpen Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
