Skip to main content

Module 7: System Information & Monitoring

Lesson 71: whereis Command

In this lesson, you'll learn how to use the whereis command to locate the binary, source code, and manual page files for any command on your Linux system and how to use it to diagnose path conflicts, verify installations, and audit command locations in scripts.

The whereis command searches a fixed set of standard directories defined by the system (such as /usr/bin, /usr/sbin, /usr/share/man, and /usr/src) rather than walking your entire filesystem or relying on the $PATH variable.

This makes it significantly faster than find for locating command-related files, and more thorough than which because it returns binary, source, and man page locations in a single shot.

Syntax

whereis [OPTIONS] COMMAND [COMMAND...]

Multiple command names can be passed in a single call.

Options

Option Description
-b Search for binaries only
-m Search for manual pages only
-s Search for source files only
-u Show commands that have unusual (missing) entries
-B <dir> Limit binary search to the specified directory
-M <dir> Limit manual page search to the specified directory
-S <dir> Limit source search to the specified directory
-l List the directories that whereis searches
-h, --help Display help and exit
-V, --version Display version information and exit

Understanding the whereis Output

whereis mkdir
mkdir: /usr/bin/mkdir /usr/share/man/man1/mkdir.1.gz

The output format is always:

COMMAND: [binary path] [source path] [man page path]

Fields that are not found are simply omitted β€” no error is shown for missing entries. This means a result with only a binary path indicates no source or man page was found in the standard search directories.

Note: whereis only searches a predefined list of standard system directories. If a command was installed to a non-standard location (such as /opt, ~/.local/bin, or a custom prefix), whereis may not find it. Use find or which in those cases.

1. Locate Files for a Single Command

whereis fswatch
fswatch: /usr/bin/fswatch /usr/share/man/man1/fswatch.1.gz
whereis rm
rm: /usr/bin/rm /usr/share/man/man1/rm.1.gz
whereis mkdir
mkdir: /usr/bin/mkdir /usr/share/man/man1/mkdir.1.gz

For standard system commands, whereis returns both the binary path and the compressed man page location. The .gz extension on the man page is normal β€” man decompresses it automatically when you run man mkdir.

2. Locate Files for Multiple Commands at Once

whereis ls cp mv rm
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz
cp: /usr/bin/cp /usr/share/man/man1/cp.1.gz
mv: /usr/bin/mv /usr/share/man/man1/mv.1.gz
rm: /usr/bin/rm /usr/share/man/man1/rm.1.gz

Passing multiple command names in a single call is faster and cleaner than running whereis repeatedly. Use this when auditing a set of commands or verifying that a group of tools is all properly installed.

Pro TecMint Β· Root Plan
This Article is for Root Members
Join Root to read the full article and unlock everything

Full Access to Every Article, Course & Certification Track

Join thousands of Linux professionals who use Pro TecMint to advance their careers.

Ad-free access to all premium articles
All courses: Learn Linux, Bash, Golang, Ubuntu and more
RHCSA, RHCE, LFCS & LFCA certification prep
New courses added every month
Private Telegram community & priority support
Root Plan
$8/mo
or $59/year billed annually
Save $37 with annual plan
Start Reading This Article in the Next 60 Seconds
Join Root Plan β†’