13

If I were to install the same application both as a snap and using APT, how would I be able to call each one separately and how would I know which one was running?

I am not yet fully convinced that snap is best for the end-user and want to compare the performance of a few packages.

  • You can search the name of the program using Htop (F3 key as the shortcut ) and then see the full path of the binary . If it was like /snap/bin/.... then it's a snap program. Or if you prefer using "ps " , run "ps -ef | grep program " – Parsa Mousavi Jun 6 at 10:10
  • If I type buckle<tab><tab> to get what options are available, I can see "buckle bucklespring.buckle" as the result, then if I use whereis buckle it responds /usr/games/buckle telling me it was deb package installed. If I whereis bucklespring I get /snap/bin/bucklespring.buckle telling me it's a snap. (Why I have both I do not know!!?). I could select via path, but don't need to in this case due to name difference.. – guiverc Jun 6 at 10:28
  • Apt isn't a "version", it's a package manager and has nothing to do with this question. (In fact, you can have a Ubuntu system without apt, it wouldn't be very convenient but it's possible) – Braiam Jun 9 at 13:03
  • No, snap is not only a package manager, it is also a file format (a package) in the same way that deb are also package. apt is a front end for dpkg and repository manager. You can add repositories and your packages would be installed by apt, yet the answers below wouldn't be applicable to those packages. In other words: it's snap repositories vs ubuntu repositories. – Braiam Jun 9 at 14:26
  • Due to the rollback war between OP and editors (FYI: the edits were beneficial and should have been kept) I have rolled back to the acceptable version with some modifications and locked this post for a week to let everyone cool down. No more activity is accepted on this post in the interim until the lock expires. Go cool off, everyone. – Thomas Ward Jun 9 at 14:34
12

Call each one separately

You can start a specific version of an application by providing the full path name of the executable. Firefox, e.g., installed using APT will be launched by /usr/bin/firefox. The executables of snap applications are under /snap/bin/ so /snap/bin/firefox will launch the snap version.

Typing firefox will launch the APT version, because /usr/bin is listed earlier in the search path than /snap/bin in a default Ubuntu install. The default PATH is:

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

When you simply type firefox, the system searches each of the consecutive directories (folders) until an executable with the name firefox is found. If the APT version is installed, it will find the executable in /usr/bin before searching /snap/bin, so the search will be stopped and that executable will be launched.

You can learn which executable will be launched with the command which.

$ which firefox
/usr/bin/firefox

You can learn which executables you have installed with the command whereis:

$ whereis firefox
firefox: /usr/bin/firefox /usr/lib/firefox /etc/firefox /snap/bin/firefox /usr/share/man/man1/firefox.1.gz

Here, both the APT and the snap version of firefox are installed.

Know which one is running

Running processes

The command ps ax lists all running processes. Thus:

ps ax | grep firefox

will list all processes with the name "firefox". The output includes the full pathname of the executable.

Creator of a specific window

It is also possible to identify the creator of a specific window, to learn whether the open window is from the APT or the snap version. However, this is rather complicated and not always reliable. See the Unix & Linux Stackexchange questions here and here.

| improve this answer | |
  • "installed using APT" note, that there are repositories that have versions of programs that don't install binaries on /usr/bin or /bin. Installing using apt doesn't mean that it would always be on the standard directories. (The binaries could reside on /opt or /usr/local) – Braiam Jun 9 at 13:06
8

Examples using gnome-calculator, which many folks have in both deb and snap formats:

  • How to call each one separately: Let's find full paths.

    $ which -a gnome-calculator     # -a keeps searching after the first hit
    /usr/bin/gnome-calculator
    /snap/bin/gnome-calculator
    
    $ whereis -b gnome-calculator   # -b returns binaries only
    gnome-calculator: /usr/bin/gnome-calculator /snap/bin/gnome-calculator
    
  • How to determine which one is running. In this example, BOTH are running. The difference is readily apparent.

    $ ps -x | grep gnome-calculator
    69445 ?        Sl     0:05 /snap/gnome-calculator/748/usr/bin/gnome-calculator
    69549 pts/0    Sl     0:01 gnome-calculator
    69727 pts/0    S+     0:00 grep --color=auto gnome-calculator
    
    $ pgrep -af gnome-calculator
    69445 /snap/gnome-calculator/748/usr/bin/gnome-calculator
    69549 gnome-calculator
    
| improve this answer | |
  • 1
    You might better use pgrep -a (or pgrep -af to match the full command line) instead of piping ps and grep. – Byte Commander Jun 9 at 17:03
  • @ByteCommander added pgrep example, thanks. – user535733 Jun 10 at 1:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.