completely remove snap from your linux system


for those who don't know what snap is, tl;dr: it's an alternative package manager made by Canonical (the developers of Ubuntu), and being pushed as a replacement of Debian's apt. problem is, it has a lot of flaws: being closed-source, blocking specific packages behind it (Firefox, Chromium...), executing itself when you try to install a package via apt, etc. i talk about some of these flaws in my anonymous services and tools guide.

it is installed by default in Ubuntu (and its derivatives), along with a few packages (Firefox, Thunderbird...). hopefully, you can remove it easily with a few commands.

  1. list and delete all snap packages: you can list all of the currently installed packages with the snap list command. next, delete all snap packages in order. some packages cannot be removed until all of the packages that depend on it are removed. start with the basic packages like firefox, thunderbird, gtk-common-themes, etc. then delete the rest of the packages. if you try deleting a package that still has dependant packages, it will tell you.

  2. remove the snap daemon: now that all snap packages have been removed, we can now remove snapd.

  3. delete the snap directories if they are still present: next, try to delete these four directories. in some cases, the only one still present on the system after the purge is the first one.

  4. prevent snap from reinstalling: finally, we can add an apt rule to disable snap from reinstalling:
    1. create a new apt preference file: sudo nano /etc/apt/preferences.d/nosnap.pref
    2. add these lines to disable snapd from reinstalling:
    3. Package: snapd
      Pin: release a=*
      Pin-Priority: -10

    4. save the file and sudo apt update.
    5. extra: because Mozilla software is only available by default on snap, trying to install Firefox or Thunderbird will give you an error telling you snapd cannot be installed. to fix this:
      1. add the official Mozilla PPA via apt.
      2. add these lines in the nosnap.pref file we made earlier to disable Firefox and Thunderbird from downloading via the official Ubuntu repositories (which are just a facade for snap):
      3. Package: thunderbird*
        Pin: release o=Ubuntu
        Pin-Priority: -10

        Package: firefox*
        Pin: release o=Ubuntu
        Pin-Priority: -10

you can now use your Ubuntu system without any snap disturbance.