What is whereis Linux command?
The Linux whereis command is a useful utility for locating the binary, source, and man page files of a given command. It helps users quickly identify the location of executable files on their system.
whereis Syntax:
Section titled “whereis Syntax:”whereis [option] [parameter]
whereis Options:
Section titled “whereis Options:”Option | Description |
---|---|
-b | Search only for binaries |
-m | Search only for manual pages |
-s | Search only for source code |
-u | Search only for unusual entries (not binaries, manual pages, or source code) |
-B | Specify the location of binary directories |
-M | Specify the location of manual page directories |
-S | Specify the location of source code directories |
Parameters:
Section titled “Parameters:”Parameter | Description |
---|---|
name | The name of the file or command to search for |
whereis Command Usage Examples:
Section titled “whereis Command Usage Examples:”Find the location of the ls command
Section titled “Find the location of the ls command”whereis ls
Locates the binary, source code, and manual page files for the “ls” command.
Locate the location of the nano text editor
Section titled “Locate the location of the nano text editor”whereis nano
Returns the paths to where the binary, source, and manual pages for the “nano” text editor are stored.
Search for the location of the gcc compiler
Section titled “Search for the location of the gcc compiler”whereis gcc
Shows the paths of the binary, source code, and manual pages related to the GNU Compiler Collection (gcc).
Check the location of the Python interpreter
Section titled “Check the location of the Python interpreter”whereis python
Displays the paths of the binary executable, source code, and manual pages for the Python programming language interpreter.
Find the path of the vi text editor
Section titled “Find the path of the vi text editor”whereis vi
Identifies the locations of the binary executable, source code, and manual pages for the “vi” text editor.
How do I use whereis in Linux?
Section titled “How do I use whereis in Linux?”To use the whereis command in bash, execute the following command:
whereis ls
How can I search for multiple commands using whereis?
Section titled “How can I search for multiple commands using whereis?”To search for multiple commands, you can specify the command names separated by spaces in the whereis command like this:
whereis ls cat mkdir
How can I search for only binaries using whereis?
Section titled “How can I search for only binaries using whereis?”To search for only binary files and not include source and manual pages, you can use the -b
option with the whereis command:
whereis -b ls
How can I list only the source files using whereis?
Section titled “How can I list only the source files using whereis?”To list only the source files related to a command, you can use the -s
option with whereis like this:
whereis -s cat
How can I display the paths in which the found files are located using whereis?
Section titled “How can I display the paths in which the found files are located using whereis?”To display the paths where the found files are located, you can use the -l
option with whereis like this:
whereis -l grep
How can I update the cache used by whereis for a more accurate search?
Section titled “How can I update the cache used by whereis for a more accurate search?”To update the cache used by whereis, you can use the updatedb
command to update the file database like this:
sudo updatedb
How can I ignore specific directories when searching with whereis?
Section titled “How can I ignore specific directories when searching with whereis?”To ignore specific directories during the search, you can use the -f
option followed by the directory you want to exclude like this:
whereis -f /usr/bin ls
Applications of the whereis command
Section titled “Applications of the whereis command”- Locating binary executable files
- Finding the location of source code files
- Determining the location of manual pages for commands