🔍 See Original Answer on Ask Ubuntu ⧉ 🔗
How to get the location of a program in Ubuntu terminal?
July 1, 2018
Edited: June 12, 2020
December 3, 2023
Copy to clipboard: false
/assets/js/search.js will update text..
As David Foerster already mentioned, you can use
type -a which will show all the locations a given executable can be found in the active
$ type -a now now is /home/rick/bin/now now is /mnt/e/bin/now
type -a will also identify if the command is a shell built-in. For example:
$ type -a test test is a shell builtin test is /usr/bin/test
type -a will also identify if the command is a shell keyword. For example:
$ type -a if if is a shell keyword
type a lists programs, commands, shell built-ins and shell keywords in the hierarchal order they would be called depending on the
$PATH environment variable. By changing
PATH= to a different order it changes which version of the program is called. This is handy when you have production, development and test program versions on the same machine.
Program isn’t in $PATH
What if the program isn’t in your path? The fastest way of finding it is with the
$ locate .bashrc /etc/bash.bashrc /etc/skel/.bashrc /home/rick/.bashrc /home/rick/.bashrc~ /mnt/e/.bashrc /mnt/e/Temporary Work/.bashrc /usr/share/base-files/dot.bashrc /usr/share/doc/adduser/examples/adduser.local.conf.examples/bash.bashrc /usr/share/doc/adduser/examples/adduser.local.conf.examples/skel/dot.bashrc
I kind of cheated here because
.bashrc isn’t a real executable, it’s a “source” file to include in a bash script which is an executable. However it serves to illustrate appropriately.