In recent long term support (LTS) releases of Ubuntu, Canonical has been adding more and more packages that are installed using snapd.
Snapd is a package manager that relies on static linking of dependencies, contrary to over two decades of Linux managing dependencies via dynamic linking, with Debian being the pioneer of this approach.
On desktop systems, packages like Firefox on Ubuntu are now forced to be in Snapd, rather than Debian. This is annoying, and counter intuitive for many reasons. Suffice it to say that those who have been using repositories in Debian format know that they get a robust system with minimal dependency issues, while also staying up to date at the same time.
Ubuntu Server LTS
So if you are like me and want to get rid of snap on your system, here is how to do it on Ubuntu Server LTS 22.04.
Which Packages are Installed via Snapd?
First, list the packages that are installed via snap, using this command:
snap list
The output will be similar to this:
Name Version Rev Tracking Publisher Notes
core20 20230613 1950 latest/stable canonical** base
lxd 5.0.2-838e1b2 24322 5.0/stable/? canonical** -
snapd 2.59.5 19457 latest/stable canonical** snapd
Shutdown LXD
We need to remove all of those, but before we can remove lxd, we need to shut it down first:
sudo lxd shutdown
Remove Snapd Packages
Then remove the packages that are installed via snap:
sudo snap remove lxd
sudo snap remove core20
Remove Snapd Itself
And finally remove snapd itself, first from snap, then from apt:
sudo snap remove snapd
sudo apt remove snapd
Xubuntu Desktop LTS (XFCE)
If you have an Xubuntu desktop system that runs XFCE, upgrading from 20.04 LTS to 22.04 LTS will force you to use snap for Firefox, which is very annoying.
When using the command do-release-upgrade, a warning popup dialog will be displayed like this.
Upgrade to the firefox snap
Starting in Ubuntu 22.04, all new releases of firefox are only available to
Ubuntu users through the snap package.
This package update will transition your system over to the snap by installing
it.
It is recommended to close all open firefox windows before proceeding to the
upgrade.
Still, you can remove snap totally, using a similar set of commands:
snap list
And you will see output like this, showing all snap packages:
Name Version Rev Tracking Publisher Notes
bare 1.0 5 latest/stable canonical** base
core22 20240408 1380 latest/stable canonical** base
firefox 126.0-2 4259 latest/stable mozilla** -
gnome-42-2204 0+git.510a601 176 latest/stable canonical** -
gtk-common-themes 0.1-81-g442e511 1535 latest/stable canonical** -
snapd 2.62 21465 latest/stable canonical** snapd
We now need to remove all the snap packages:
This initial command will take some times, and display various steps it is going through.
sudo snap remove firefox
The following commands are fast.
sudo snap remove gtk-common-themes
sudo snap remove gnome-42-2204
sudo snap remove core22
sudo snap remove bare
sudo snap remove snapd
Then we remove the snap daemon itself.
sudo apt purge snapd
The output will be something like this:
...
The following packages will be REMOVED:
firefox* firefox-locale-en* snapd*
Do you want to continue? [Y/n]
...
Removing firefox-locale-en (1:1snap1-0ubuntu2) ...
Removing firefox (1:1snap1-0ubuntu2) ...
Removing snapd (2.62+22.04) ...
...
(Reading database ... 199659 files and directories currently installed.)
...
Discarding preserved snap namespaces
Final directory cleanup
Removing extra snap-confine apparmor rules
Removing snapd cache
Removing snapd state
Purging configuration files for firefox (1:1snap1-0ubuntu2) ...
You can now proceed with installing Firefox or Firefox ESR from the Ubuntu Mozilla Team's PPA, as per this article.
Conclusion
Whether you have a server, or a desktop running XFCE, you now have a snapd free server system ...
Most Comments
Most commented on articles ...