Display an executable’s location with which command

by Daniel Pham
Published: Updated:
This entry is part 3 of 9 in the series Linux commands: Part 5 - Working with commands

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.

Recommended Reading: The command types are in the Linux systems

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
use which command to display location of python file
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.

which command can not display location of a shell builtin as cd
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.

(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).

0 0 votes
Article Rating
Series Navigation«« Previous part: Type command to display a command’s typeNext part: Get help for shell builtins with help command »»

You may also like

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

DevOps Lite is a personal blog specializing in technology with main topics about DevOps, DevSecOps, SRE and System Administrator. Articles are shared for free and contributed to the community.

SUPPORT US

FOLLOW US

Subscribe my Newsletter for new blog posts. Stay updated from your inbox!

© 2021-2024 DevOpsLite.com – All rights reserved.

Please write sources “DevOpsLite.com” when using articles from this website.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

2
0
Would love your thoughts, please comment.x
()
x

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.