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.
- 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.
- remove the snap daemon: now that all snap packages have been removed, we can now remove snapd.
- first, stop the daemon: sudo systemctl stop snapd.
- second, disable the daemon: sudo systemctl disable snapd.
- third, mask the daemon: sudo systemctl mask snapd.
- finally, purge the daemon and set it on hold: sudo apt purge snapd && sudo apt-mark hold snapd.
- 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.
- ~/snap/
- /snap/
- /var/snap/
- /var/lib/snapd/
- prevent snap from reinstalling: finally, we can add an apt rule to disable snap from reinstalling:
- create a new apt preference file: sudo nano /etc/apt/preferences.d/nosnap.pref
- add these lines to disable snapd from reinstalling:
Package: snapd
Pin: release a=*
Pin-Priority: -10
- save the file and sudo apt update.
- 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:
- add the official Mozilla PPA via apt.
- 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):
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.