Fundamentals 3 min read

Master the Linux whereis Command for Lightning‑Fast File Location

This guide explains how the Linux whereis command quickly locates binaries, source files, and manual pages by querying a system database, details its options, shows practical examples, and warns about the database's weekly update cycle.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master the Linux whereis Command for Lightning‑Fast File Location

Command Syntax

whereis [options] filename

Purpose

whereis locates the executable, source code, and manual (help) files of a given program name. It can also search for unusual items and specify alternative search paths.

How It Works

Unlike find, whereis reads from a pre‑built database that records the locations of all files, making searches extremely fast. The database is refreshed only about once a week, so recent changes may not be reflected.

Options

-b  Locate binary (executable) files.

-m  Locate manual/help files.

-s  Locate source code files.

-u  Search for files outside the default binary, source, and help categories.

-B  Specify a custom search path for binaries.

-M  Specify a custom search path for manual files.

-S  Specify a custom search path for source files.

Examples

whereis ls
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz
whereis -b ls
ls: /usr/bin/ls
whereis -m ls

Note: The last command returns no output if the manual page is not found in the database.

LinuxUnixcommand-linewhereisfile-location
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

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.