This brief tutorial shows students and new users how to use the whereis command on Ubuntu to find binary, source, and help manual pages for a given command.
The whereis command in Ubuntu Linux is a useful tool that helps users locate a given command’s binary, source, and manual help pages. If you are new to Linux or Ubuntu, the whereis command can be very helpful in finding the location of a command, its source code, and the corresponding manual pages.
It can also help to identify the various lookup paths where the command is located. The whereis command is very easy to use and has several options that allow you to customize your search according to your needs.
Using the whereis command, you can quickly find the location of a command and its associated files, which can be very helpful when troubleshooting issues or when you need to modify a command’s behavior.
About whereis command:
The whereis command is a command line utility that helps you find the locations of other commands’ binary, source files, and manual help pages.
Syntax:
The syntax is the rule and format of how the whereis command can be used. These syntax options can be reordered, but a straight format must be followed.,.
Below is an example syntax of how to use the whereis command.
whereis [options] command.
Options:
The command line options are switches or flags that determine how the commands are executed or controlled. They modify the behavior of the commands. They are separated by spaces and followed after the commands.
Below are some options for the whereis command:
command | Replace command a command you want to search for |
-b | If you use the -b option, the whereis command searches for a command’s binary file only. |
-m | Use the -m option to only search for a command’ manual file and related information only |
-s | Use the -s option to force whereis command to only search for a command source file only |
-l | The –l option displays the output of the effective lookup paths for whereis command |
–help | Display a help message and exit. |
Examples:
Below are some examples of how to run and use the whereis on Ubuntu Linux.
Simply run the whereis to invoke it.
If you want to use the whereis command to find the binary, source file, and manual help pages for the bash command, simply run the command below:
Example:
whereis bash
When you run the above command, a similar line below should be displayed on your screen with the binary file, source, and help pages for the bash command:
Output:
bash: /bin/bash /etc/bash.bashrc /usr/share/man/man1/bash.1.gz
The line above shows /bin/bash as the binary command file, /etc/bash.bashrc as its source, and /usr/share/man/man1/bash.1.gz as its manual page.
To list and identify all the location paths that the whereis command searches, simply run the whereis command with the -l option:
Example:
whereis -l
To search for a command’s binary file only and not include its source and help pages, run the whereis command with the -b option.
Example:
whereis -b bash
To display a command’s source file only without its binary file or help pages, run the where’s command with the -s option:
whereis -s bash
To display information for more than one command, simply include multiple commands when running the whereis command:
Example:
whereis bash nano
You should see the output below:
Output: bash: /bin/bash /etc/bash.bashrc /usr/share/man/man1/bash.1.gz nano: /bin/nano /usr/share/nano /usr/share/man/man1/nano.1.gz /usr/share/info/nano.info.gz
That’s it!
Congratulations! You have learned how to use the whereis command on Ubuntu Linux.
Leave a Reply Cancel reply