Last Updated : 09 Sep, 2024
'whereis' command is used to find the location of source/binary file of a command and manuals sections for a specified file in Linux system. If we compare 'whereis' command with 'find' command they will appear similar to each other as both can be used for the same purposes but 'whereis' command produces the result more accurately by consuming less time comparatively. 'whereis' doesn't require any root privilege to execute in any RHEL/CentOS 7.
The 'whereis' command in Linux is a powerful tool used to locate the binary, source, and manual sections of a specified command. It is a quick and efficient way to find the location of files related to system commands without requiring root privileges. Unlike the 'find' command, which searches the entire file system, 'whereis' searches through a predefined set of directories, making it faster and more accurate.
Here, we will explore how to use the 'whereis' command, its syntax, options, and practical examples to help you effectively locate files in a Linux environment.
What is the 'whereis' Command?The 'whereis' command is used to find the location of the source, binary, and manual sections of a command in the Linux system. It scans standard directories in the file system and returns paths to binaries, source code, and man pages associated with the specified command. The command simplifies system administration by quickly locating essential files without the need for extensive search options or root access.
Points to be kept in mind while using 'whereis' command:Syntax:
whereis [options] filename...whereis command Examples in Linux
Let us look at some of the examples of 'whereis' command in Linux to better understand the concept.
Example 1: Finding the Location of the apropos CommandLet's say, we want to find the location of apropos command then we need to execute the following command in the terminal:
Example 2: Finding the Location of the 'lshw' CommandTo find the location of 'lshw' command.
Options Available with the whereis Command 1. -b(Search for Binaries Only)This option is used when we only want to search for binaries.
Example: To locate binary of a Linux command let's say gunzip.
This option is used when we only want to search for manual sections.
Example: To locate man page of false command.
This option is used when we only want to search for sources.
4. -u(Search for Unusual Entries)This option search for unusual entries. A source file or a binary file is said to be unusual if it does not have any existence in system as per [-bmsu] described along with “–u”. Thus `whereis -m -u *' asks for those files in the current directory which have unusual entries.
Example: To display the files in the current directory which have no documentation file.
This option is used to change or otherwise limit the places where whereis searches for binaries.
Example: To locate binary of 'lesspipe' in the path, '/bin'.
This option is used to change or otherwise limit the places where whereis searches for manual sections.
Example: To check man page of intro that is only in a specific location i.e. '/usr/share/man/man1'.
This option is used to change or otherwise limit the places where whereis searches for sources.
Example: To Find all files in '/usr/bin' which are not documented in /usr/man/man1 with source in '/usr/src'.
This option simply terminate the last directory list and signals the start of file names. This must be used when any of the -B, -M, or -S options are used.
9. -V(Display Version Information)Displays version information and exit.
Displays this help and exit.
The 'whereis' command in Linux is a versatile and efficient tool for locating binaries, source files, and manual sections of commands in your system. By understanding and utilizing its various options, you can quickly identify where commands are stored, making it easier to manage and maintain your Linux environment. Mastering the 'whereis' command can enhance your efficiency and productivity in navigating and managing command locations.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4