How to know the path of a particular software?
Find the path of an executable
Best way
type executable
Check out this question to learn more about how type
is better. (Thanks, comments!)
Other ways
whereis executable
which executable
Those commands only search in the PATH variable (echo $PATH
), thus they are not valid in some cases (built-in functions, aliases, or bash functions, and more).
Find command location inside or outside of path
Assume you want to find the location of uname
, a program that lists system information. If you want to know what directory the top level command is stored in you have a number of options:
$ which uname
/bin/uname
$ type -a uname
uname is /bin/uname
$ command -v uname
/bin/uname
$ locate uname
/bin/uname
(... SNIP dozens of Windows files on C & D ...)
/usr/lib/klibc/bin/uname
/usr/lib/plainbox-provider-resource-generic/bin/uname_resource
/usr/share/man/man1/uname.1.gz
/usr/share/man/man2/oldolduname.2.gz
/usr/share/man/man2/olduname.2.gz
/usr/share/man/man2/uname.2.gz
Locate advantages
The last option locate
returns all files containing uname
not just the program that is run from the command prompt.
The advantage of locate
is it will find commands not in your search path. type -a
(preferred over simple type
) and which
will only find commands in your search path. To see your search path use echo $PATH
.
Take for example this answer in How to start screencloud? :
Try...
/opt/screencloud/screencloud.sh
The locate screencloud
command will find it but which screencloud
and type -a screencloud
will not because:
- The full name is
screencloud.sh
and onlylocate
command searches on partial match. -
/opt/screencloud
probably isn't in the search path.which
andtype
only look for executable files in search path.
Note: This is an older answer. Modern ScreenCloud is called with screencloud
.
Locate's advantage over the find
command is it can be hundreds or even thousands of times faster. Also running find
starting from /
will give many permission errors you won't experience with locate
.
Locate disadvantages
If you just installed the program today you will need to use sudo updatedb
to update locate's database.
Use the following command to list all of your $PATH
directories:
echo $PATH | sed 's/:/\n/g'
Use the following command to find the full path for screencloud
:
for i in $(echo $PATH | sed 's/:/\n/g'); do find $i/screencloud* 2>@1; done
If you used apt
, apt-get
, or the Ubuntu Software Center to install the package, you can use the following command to find the full path:
dpkg -L screencloud | grep bin
Assuming you used this repository, you should be able to find screencloud
in /usr/bin/
.
The full path is:
/usr/bin/screencloud
or
/usr/bin/screencloud-*
However, if you used the snapcraft store according to the link you provided in your question, then the path would be under the following directory:
/snap/bin
more info
Also, please remember that Ubuntu is case sensitive so you must use all lowercase with no capital letters.