13

Context: I'm trying to make an application automatically start when I login. For this I need to select the path for the application.

enter image description here

Here are the paths I already looked into:

  • /sbin
  • /usr/sbin
  • /usr/local/bin
  • /usr/share/

If this may help, the application I'm trying to find is called "ScreenCloud" and I downloaded it from the Ubuntu Software Center.

But I cannot find it, is there any way I can know where is installed a particular software? Because even if I found for this one, I would like to avoid having the same issue in the future.

6
  • 2
    Does it not work if you just type screencloud in the command line?
    – graham
    May 15, 2019 at 15:50
  • Did you get it from the snap store or from the Ubuntu software center because I cannot find it in any of the Ubuntu apt repositories.
    – mchid
    May 16, 2019 at 0:53
  • 2
    @mchid I wasn't addressing OP's link but rather your comment: "because I cannot find it in any of the Ubuntu apt repositories" Screencloud can be installed from .deb package but you need to add PPA. May 16, 2019 at 22:46
  • 1
    @mchid I knew the command was changed from screencloud.sh to screencloud and suspected it was moved out of /opt. That part of my answer was pointing out how type and which wouldn't find screencloud but locate would. May 17, 2019 at 12:55
  • 1
    @WinEunuuchs2Unix Right on. screencloud.sh actually still exists but I am not sure how it differs from screencloud other than the fact that the .sh file is a script and screencloud is not. I really am not familiar with this application. Under /usr/bin/ there is a screencloud, a screencloud.sh, and also a screencloud- followed by the version number sort of like how gimp is.
    – mchid
    May 20, 2019 at 0:13

3 Answers 3

16

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).

9
  • 3
    incredibly enough this was not yet a question on ask ubuntu. good question @Ced!
    – tatsu
    May 15, 2019 at 15:48
  • Indeed, I can hardly believe it!
    – Biggybi
    May 15, 2019 at 15:49
  • 1
    I found out from another question that type is preferred over which as it's a shell builtin and can determine whether a command is an alias. That was new to me too!
    – Arronical
    May 15, 2019 at 16:25
  • 1
    See here for a (long) explanation of why type is preferred: Why not use "which"? What to use then?
    – terdon
    May 15, 2019 at 17:50
  • 1
    @mchid the points in the answer all apply. Including the "Use Cases" section which points out that which is indeed useful in the specific context of shell scripts. Outside that context, however, type is almost always the better choice.
    – terdon
    May 21, 2019 at 7:54
1

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 only locate command searches on partial match.
  • /opt/screencloud probably isn't in the search path. which and type 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.

1

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.

2
  • Thank you for this very detailed answer, you won an upvote:)
    – Ced
    May 16, 2019 at 18:58
  • 1
    It was effectively under /snap/bin!
    – Ced
    May 20, 2019 at 6:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .