Operations 4 min read

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.

Open Source Linux
Open Source Linux
Open Source Linux
Master Linux’s whereis Command: Fast File Location Explained
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]... filename

Command 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.gz

Show the binary of ls

whereis -b ls
ls: /usr/bin/ls

Show the manual of ls

whereis -m ls
LinuxUnixfile searchcommand-linewhereis
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.