There are many times when you have an application with multiple different versions. It sometimes becomes confusing to figure out which command to use the appropriate version of the software. A command example would be of Python.
Most Linux users have a pre-installed version of python 2.7 on their systems. Since Python 2.7 is officially dead now, you would naturally want to use Python 3, whether you are a beginner or professional, who writes large-scale applications. This is where
which command comes in.
It tells you about the location of the binary used for executing the command. The following commands and their output reflect the binaries used to run the command
-> % which python /usr/bin/python2 -> % which python3 /usr/bin/python3 -> % which python3.8 /usr/bin/python3.8
So, in case you are confused about whether the command is exactly using the correct version of the application you want to use,
which is the command for you to use.
You can also pass multiple arguments to
which separated by a space. e.g
-> % which python python3 /usr/bin/python /usr/bin/python3
We hope the command
which helps you find whether the correct binary is being used for your command or not. We hope this post helps you in finding out the relevant information that helps you in your end goal. In case you are interested in learning about some other commands, you may visit this page.
Till, we meet again in another blog post, keep hacking !!!