The first thing I did after installing Ubuntu 22.04 LTS was to remove Snap and its snap packages completely. I’m not proud of that approach as I have nothing against snap packages per se; I simply enjoy using apt (Advanced package tool).
This is for sure an option, also see Best Linux Distros for Beginner, Experienced and Expert users. However, if you prefer to stick with Ubuntu, swapping distros isn’t an option. So you will have to either keep Snap, remove it or replace it. Also, don’t forget another alternative which is Appimage.
Why remove Snap from Ubuntu?
systemd was released in 2010 and, over time, started to replace
init systems by default in various distros, I was all-in for systemd from the start. Like systemd, snap is also open source. However, the snapd (snap daemon) is hardcoded to use Canonical’s servers for fetching snaps and all metadata associated with them. Also, the code for those backend servers is not open source.
Although flawed in some areas, I have a lot of praise for Canonical’s management of Ubuntu – especially Ubuntu server and the approach to enterprise Linux. Maybe they will eventually address these transparency and security concerns.
It was not too long ago that Canonical tried to convince many of us to use their Unity desktop environment. I was not too fond of Unity desktop and although removing it was possible, it was not because Canonical made it easy to opt-out. Like Unity, today, I don’t feel like I’m missing out on much by not using snap.
Before uninstalling Snap from Ubuntu
To ensure that you make an informed decision, here is the response from a Canonical team member on the effects of removing Snap. Specifically from Ubuntu 22.04 LTS:
“You will lose access to any software installed via a snap package. Snap software is “containerized” (to varying extents depending on the install mode and permissions) so you would lose access to “snap” containerized software specifically. There are other ways to run containerized software you wouldn’t necessarily lose access to though are not installed or used by default and that can also be used at the same time as snap packages (e.g. flatpak, docker, etc).
There is some software installed by default on 22.04 by snap that has no Ubuntu-provided alternative “deb” package. This includes firefox and the “Ubuntu Software” store app (installed by default) and LXD (not installed by default, but if you want to use it, there is no deb package). If you’re not using any such snap software, it may not matter. In some cases, you may be able to install software through some other non-snap method from a non-Ubuntu source (e.g. you may be able to install firefox using the standard Linux installer, though I have not tried that).
With regards to the Ubuntu live kernel update feature, this is powered by the ‘canonical-livepatch’ snap. When you run “ua enable livepatch” it installs the snap. Without snap, it won’t work, hence you won’t get live patches. Livepatches are not automatically enabled by default for a standard install on your own hardware, you need to attach it to your ubuntu account with “ua attach” and then “ua enable livepatch” (it’s free for 3 personal machines and requires a paid subscription otherwise). You can read more about that at https://ubuntu.com/security/livepatch. The snap package is the only canonical-livepatch client package hence if you removed snapd you would lose access to use livepatches.”
How to remove Snap from Ubuntu 22.04 LTS
First, let’s list all the snaps installed on your system with the following command:
Let’s also stop snapd (snap daemon) services:
sudo systemctl disable snapd.service sudo systemctl disable snapd.socket sudo systemctl disable snapd.seeded.service
Then remove each snap. It’s best to do so one-by-one, rather than all in one apt remove line. So something like:
sudo snap remove firefox sudo snap remove snap-store sudo snap remove gtk-common-themes sudo snap remove gnome-3-38-2004 sudo snap remove core18 sudo snap remove snapd-desktop-integration
Now, let’s delete any leftover snap cached data:
sudo rm -rf /var/cache/snapd/
Then purge or remove completely snapd using the following command:
sudo apt autoremove --purge snapd
Finally, using purge doesn’t touch your home directory, so you can optionally delete any files previously created in ~/snap.
To do this, use the following command:
rm -rf ~/snap
Reinstalling Firefox with apt
If you want to reinstall Firefox, when you try to do so with apt, you may get the following error:
firefox : PreDepends: snapd but it is not going to be installed
You can get around that by blocking Ubuntu from pulling the snap version of Firefox by pinning it.
First, create a new file:
Next, add these lines to that new file:
Package: firefox* Pin: release o=Ubuntu* Pin-Priority: -1
Save it. Then add the Mozilla team Ubuntu PPA for Firefox:
sudo add-apt-repository ppa:mozillateam/ppa
Finally, ‘apt update’ and ‘apt install’ the latest Firefox version:
sudo apt update sudo apt install firefox
We can only hope that Ubuntu will eventually have the official option during and after installation that allows you to easily opt-out/uninstall Snap. It reminds me of how Microsoft tried to force us to use Internet Explorer and how they also made it difficult to uninstall it. Maybe something similar to the
flatpak uninstall command. Speaking of which, also check out unsnap.