How To

whereis Command in Linux: Find Binary, Source, and Man Pages

The whereis command locates the binary, source, and manual page files for a given command. Unlike which, it searches beyond $PATH, it checks hard-coded system paths and directories from environment variables.

How to Use the whereis Command in Linux

The syntax is:

bashwhereis [OPTIONS] FILE_NAME...

Run without options to search for all three types at once:

bashwhereis bash

Output: bash: /bin/bash /etc/bash.bashrc /usr/share/man/man1/bash.1.gz

Each result shows the command name, binary path, source search matches, and man page path. Most commands do not have C source files installed. When whereis returns a file from the source search paths — like /etc/bash.bashrc — it found that file in the source directories, not the actual C source code.

If the command is not installed, whereis prints only the command name with no paths.

Check multiple commands at once by listing them as arguments:

bashwhereis netcat uptime

To see exactly which directories whereis searches, use -l:

bashwhereis -l

These search paths are NOT the same as $PATH. If whereis cannot find a command you know is installed, -l shows whether its location is covered.

Filter Results by Type: Binary, Source, and Man Pages

Limit output to one type with:

  • -b – binary only
  • -m – man page only
  • -s – source files only
bashwhereis -b ping      # binary only: /bin/pingwhereis -m bash      # man page path only

When you only need the binary path, which or type are more focused. which searches $PATH; whereis -b searches the hard-coded system paths, they may return different results depending on how the command is installed.

Limit Search Paths and Find Unusual Entries

Use -B, -M, or -S to restrict the directories whereis searches. The -f flag must come after the directory list to mark where the filenames begin:

bashwhereis -b -B /bin -f cp

Output: cp: /bin/cp

The -f flag is required. Omitting it causes an error.

The -u option finds “unusual” commands — those missing one or more of the requested file types. Use it to find commands in a directory that have no matching man page:

bashcd /binwhereis -m -u *

The * expands to all filenames in /bin. whereis checks each one and reports those with no man page entry.

Use whereis command for a three-type lookup, -b/-m/-s to narrow by type, and -m -u * to audit a directory for commands missing man pages. Leave a comment below if you run into any issues.

Cyber Defence

Recent Posts

What Is a Data Protection Platform and Why Your Organization Needs One

A data protection platform is a unified system that helps organizations discover, classify, monitor, and…

1 week ago

How Swiss Privacy Rules Affect AI Companies Under GDPR

AI companies operating in or around Switzerland face a compliance challenge that most legal teams…

1 week ago

Swiss FADP vs EU GDPR: Key Differences for AI and Data Privacy

Two major data privacy laws now govern how organizations handle personal data across Europe; the…

1 week ago

Kali Linux Commands Cheat Sheet: Complete Quick Reference

This cheat sheet covers the essential Kali Linux commands every pentester and ethical hacker uses…

1 month ago

What I Wish I Knew Before Learning Malware Analysis and Reverse Engineering

When I first started learning malware analysis and reverse engineering, I thought the hardest part…

1 month ago

git fetch vs git pull: How They Work and When to Use Each

Both git fetch and git pull talk to a remote repository, but they do very different things to your…

2 months ago