Display an executable’s location with which command

Share this post to your friends !

This entry is part 3 of 9 in the series Linux commands: Part 5 - Working with commands

WriteBash - This article will guide you to use the which command to display the executable’s location.

Sometimes, on your system there will be more than one version of the executable program installed.

If you work with the Python language, you will probably understand this.

Syntax of which command

The syntax of that command is quite simple, if you have read the type command then you will have no trouble using that.

$ which command

The which command starts with the word which and follows the command you want to see, without any additional parameters.

Use which to display an executable’s location

Below, I will perform some examples with the which command. First, I will check the executable file location of the Python command.

When working with Python, sometimes you have to use version 2.6, sometimes you have to work with version 2.7 and there are times when you have to work with version 3.5.

And all those Python versions are in your system, now we’ll determine where the executable file is.

trungdung@linuxmint ~ $ which python
/usr/bin/python
trungdung@linuxmint ~ $ which python2
/usr/bin/python2
trungdung@linuxmint ~ $ which python3
/usr/local/bin/python3
display-an-executables-location-with-which-command-01 Display an executable's location with which command
Use which command to display location of python file.

Note: which command cannot use to display location of shell bultin or alias commands.

For example, I try to use the which command to view the location of the cd command. You can see it doesn’t return any results. In some other operating systems, you may receive an error message not found.

display-an-executables-location-with-which-command-02 Display an executable's location with which command
which command can not display location of a shell builtin as cd.

Conclusion

When working on the system, there are many different versions of the program, which are really useful. Remember it to use.

Continue reading the series«« Previous part: Type command to display a command’s typeNext part: Get help for shell builtins with help command »»
If you liked this article, then please subscribe to our YouTube Channel for more video tutorials. You can also find us on Twitter and Facebook.


Share this post to your friends !
If you appreciate what we share in this blog, you can support us by:
  1. Stay connected to: Facebook | Twitter | Google Plus | YouTube
  2. Subscribe email to recieve new posts from us: Sign up now.
  3. Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
  4. Become a Supporter - Make a contribution via PayPal.
  5. Support us by purchasing Ribbon Lite Child theme being using on this website.

We are thankful for your support.

single post bottom banner
«« »»

Got something to say? Join the discussion

Please keep in mind that all comments are subject to our Comment Policy. Your email address will not be published.
This site uses Akismet to reduce spam. Learn how your comment data is processed.