[email protected]Office hours: Mon – Fri 9:00AM – 5:00PMLinkedInXFacebook
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 Implement Network Segmentation and Resource Isolation in Linux.
February 6, 2024

How to Implement Network Segmentation and Resource Isolation in Linux.

How to Implement Network Segmentation and Resource Isolation in Linux. Securing and managing networks in a Linux environment involves advanced practices like network segmentation and resource isolation. This guide explores these concepts, providing detailed instructions and examples for…

Read article
How to open or close ports in Linux.
February 6, 2024

How to open or close ports in Linux.

How to open or close ports in Linux. Effectively managing ports on your Linux system is crucial for both security and service accessibility. This comprehensive guide will provide a detailed walkthrough on opening and closing ports using the robust tools iptables and ufw. Understanding these…

Read article
How to use ypdomainname command.
January 23, 2024

How to use ypdomainname command.

How to use ypdomainname command. In the realm of Linux networking, the ypdomainname command plays a crucial role in the context of the Network Information Service (NIS). NIS, formerly known as Yellow Pages, is a distributed database service that facilitates the sharing of network configuration and…

Read article
Get in Touch

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

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

Get Started →Contact Us
[email protected]Office hours: Mon – Fri 9:00AM – 5:00PM