How to use the whereis Command in Ubuntu Linux with examples

|

|

The tutorial guides students and new users on the usage of the ‘whereis’ command in Ubuntu Linux to locate binary, source, and manual pages of a given command. It also explains the syntax, command options, and provides examples. ‘whereis’ command is especially beneficial for beginners learning Ubuntu Linux, an open-source operating system for different devices.

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
    -bIf you use the -b option, the whereis command searches for a command’s binary file only.
     -mUse the -m option to only search for a command’ manual file and related information only
     -sUse the -s option to force whereis command to only search for a command source file only
      -lThe –l option displays the output of the effective lookup paths for whereis command
–helpDisplay 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.

Like this:



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.