[email protected]Support 24/7 · Billing 09:00 – 00:00LinkedInXFacebook
NexonHost
Netherlands Dedicated ServersAmsterdam · Equinix AM6Germany Dedicated ServersFrankfurt · Equinix FR4Romania Dedicated ServersBucharest · VoxilityAustria Dedicated ServersVienna · Interxion VIEBulgaria Dedicated ServersSofia · TelepointFrance Dedicated ServersParis · Interxion PAR — Marseille · Digital Realty MRS3Ireland Dedicated ServersDublin · Equinix DB2Italy Dedicated ServersMilan · Irideos AvalonPoland Dedicated ServersWarsawSpain Dedicated ServersMadrid · Equinix MD2United States Dedicated ServersAshburn · Equinix DC
All articles
Getting startedMarch 15, 2023

How to use whereis command.

How To Use Whereis Command.

In this article, we will show you how to use the Linux whereis command.

whereis is a command-line utility that allows you to find the location of the binary, source, and manual page files for a given command.

 

How to Use the whereis Command

The syntax for the whereis command is as follows:

whereis [OPTIONS] FILE_NAME...

When used without any options whereis search the binary, source and manual files for the command specified as an argument.

By default whereis searches for the command’s files in the hard-coded paths and directories listed in the environment variables . Use the -l option to find the directories where the whereis command search for.

whereis -l

For example, to get information about the bash command, you would type the following:

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

In the output above bash: is the command for which you want to get information, /bin/bash is the path to the binary file, /etc/bash.bashrc is the source file, and /usr/share/man/man1/bash.1.gz is the man page.

If the command you are searching for doesn’t exist, whereis will print only the command name.

You can also provide more than one arguments to the whereis command:

whereis netcat uptime

The output will include information about both netcat and uptime commands:

netcat:uptime: /usr/bin/uptime /usr/share/man/man1/uptime.1.gz
uptime: /usr/bin/uptime /usr/share/man/man1/uptime.1.gz

To search only for the command binaries use the -p option.

For example, to find the location of the ping command, you would type the following:

whereis -p ping
/usr/bin/ping /usr/share/man/man8/ping.8.gz

When searching only for the location of the command binary, prefer using the which or type commands.

To search only for the source files, use the -s option.

whereis -s command

If the source files exist, the whereis will print their locations.

The -m option allows you to search only for man files:

whereis -m command

To limit the locations where whereis searches for binaries use the -B options, for manuals the -M option, and -S for sources. Each option accepts a list of absolute paths to directories separated by space. The directory list must be terminated by the -f option that indicates the start of the filenames.

For example, to search for the cp binary in the /bin directory you would type:

whereis -b -B /bin -f cp
cp: /usr/bin/cp

The -u option tells whereis to search for unusual entries. Files that do not have exactly one entry of each requested type (binary, manual and source) are considered to be unusual files (commands).

For example, to search for all binaries in the /bin directory that doesn’t have manual pages or have more than one documentation you would type:

cd /binwhereis -m -u *

The wildcard character (*) after the -f option means all files in the current working directory (/bin).

 

Conclusion

The whereis utility is used to locate the binary, source, and manual files for a given command.

Keep reading
How to use Bash Sequence Expression
July 21, 2023

How to use Bash Sequence Expression

How To Use Bash Sequence Expression Bash Sequence Expression In this article, we will cover the basics of the sequence expression in Bash. The Bash sequence expression generates a range of integers or characters by defining a start and the end point of the range. It is generally used in…

Read article
How to understand  Find and Replace in Vim / Vi.
July 21, 2023

How to understand Find and Replace in Vim / Vi.

Find and Replace in Vim / Vi In Vim, you can find and replace text using the :substitute (:s) command. To run commands in Vim, you must be in normal mode, the default mode when starting the editor. To go back to normal mode from any other mode, just press the ‘Esc’ key. The general…

Read article
How to understand Linux File Permissions.
July 21, 2023

How to understand Linux File Permissions.

How to understand Linux File Permissions. In Linux, file permissions, attributes, and ownership control the access level that the system processes and users have to files. This ensures that only authorized users and processes can access specific files and directories. Linux File Permissions The…

Read article
Get in Touch

Together, Let’s Build a Faster, Safer Internet.

Build scalable infrastructure with NexonHost — high-performance dedicated servers, VPS hosting, cloud hosting, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Support 24/7 · Billing 09:00 – 00:00