Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

Which, Whereis vs. Whatis in Linux: Key Differences

Learn about Linux, including Which. Command, key uses, practical steps, common issues, and answers to frequently asked questions.

Table of Contents

This guide provides a clear overview of linux, including Which. Command, Command Whereis. Use it to understand the topic, compare the available options, and make a more informed decision.

Here is a detailed comparison of which, whereis and whatis commands on Linux.

Which. Command

Some commands have multiple binary executables located in different directories. When you run a command, the shell searches for its executable files in the directories specified in the PATH environment variable.

To find out what directories are in the PATH environment variable, open a terminal on Linux and run the following command:

echo $PATH

Tip : You can also manually add directories to the PATH environment variable.

When the shell finds the first executable path, the shell executes it. Using the which command in Linux, you can determine the path of that executable.

This is useful in cases where you have two different versions of the same program or two different programs with the same name installed on your system. Using which command you can find which command will be executed first.

Here is the syntax of which command:

which [option] [command]

For example, to check the actual path of the tar command, you would type:

which tar

Which. Command - Linux

This command will show the first executable path i.e. /usr/bin found for the tar command in the PATH. This means that whenever you run the tar command, the shell will execute the binary located in the /usr/bin directory.

To display all available executable paths for a command, use the which command with the -a option:

which -a tar

You can also display the execution paths for multiple commands at once as follows:

which [command1] [command2] [command3]

Command Whereis

The whereis command displays the path of the binary, the source, and the manual page associated with the specified command. Unlike the which command, it searches not only the executable in $PATH but also $MANPATH and other predefined locations.

Without any command line options, the whereis command displays the binaries, source and manual pages for a command:

whereis tar

Command Whereis - Linux

To display only the binary file path, use the -b option:

whereis -b tar

To display only the source file, use the -s flag:

whereis -s tar

To display only the manual page, use the -m option:

whereis -m tar

Whatis. Command

The whatis command provides a one-line description of the given Linux command. It finds this information from the command's manual page.

For example, to find out what the tar command does, run:

whatis tar

Whatis. Command - Linux

You can also find information about multiple concurrent commands using:

whatis ls cp mkdir cat head

Difference Between Which, Whereis and Whatis in Linux

If you are looking for the path of the binary to be executed when a command is run in the shell, use the which command. If you are looking for sources, binaries and manual pages for a command, use whereis.

The whereis command lists all binary executables while the which command only shows the first file that is executed when you enter said command in the shell.

The which command searches the PATH variable, while the whereis command searches standard Linux directories, including $PATH and $MANPATH.

Finally, the whatis command only shows the one-line description of the command.

Conclusion

Understanding Linux makes it easier to compare options, avoid common mistakes, and apply the information in this guide more effectively. Review the relevant requirements before making changes or choosing a solution.

FAQ

What is Linux?

Here is a detailed comparison of which, whereis and whatis commands on Linux.

Why is Linux important?

Understanding Linux helps you evaluate features, compatibility, performance, and potential limitations before you choose a product or follow a procedure.

What should you consider when using or choosing Linux?

Consider your specific goal, compatibility requirements, available features, cost, security, and the practical recommendations described in this guide.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.