Removing Snap and Using Flatpak on Ubuntu

I used Ubuntu for many years. It was the most compatible operating system for the computers that I had at the time. I had heard about Debian. However, the Debian webpage is hardly the gold standard for making it easy to install an operating system, when someone is new to the whole process.1 Ubuntu made it easy to understand how to install Linux. Once installed, it was easy to figure out how to do things on the system because many online guides focused on doing things on Ubuntu, and ignored other distributions completely. “How to install Thunderbird on Linux” will usually lead to a guide for installing Thunderbird on Ubuntu.2 I stopped using Ubuntu when they introduced Snap. Snap is a strange, hard-to-use amalgam of a package manager and app store. Ubuntu insists on using Snap even for the core parts of an operating system (such as the desktop environment Gnome) Snap insists on making the Gnome “Snap” a required dependency of the “Firefox” Snap! Finally, the file sizes are unreasonably big. This is a short guide to removing all the Snaps on a fresh Ubuntu installation and using Flatpak instead.

Stop Using Snap

Snap has many components and disabling all of them is essential. This section borrows from How to Remove and Disable Snap | Baeldung on Linux, with a couple of useful notes along the way.

1. Using Vanilla Gnome

On Ubuntu 26.04 LTS, the desktop environment is Ubuntu Gnome, which is itself a wrapper around Gnome. This can not be used as-is if you want to remove Snap (I believe) because we will be uninstalling all Snaps from the system and disabling it completely. To get around this and continue using Gnome, I suggest the use of the vanilla-gnome-desktop package, which provides a much better experience, and will retain desktop environment familiarity if you were ever to switch to another distribution.

apt install vanilla-gnome-desktop

After installation, log out and log in. During log-in, use the gear icon on the bottom right of the screen where you would enter the login password, and select Gnome instead of Ubuntu. This will switch the desktop environment to Vanilla Gnome, and break 50% of your ties with Ubuntu.

2. Remove All Snaps

The first step would be to remove all the installed Snaps:

snap list | awk 'NR > 1 { print $1 }' | xargs -I{} sudo snap remove {}

This command will not work the first time around: This is because snap list lists the snaps (say) bare and firefox. bare can not be removed on the first iteration, because the firefox snap depends on the bare snap. So, the first iteration will remove only those Snaps which are at the “leaf node” of the dependency tree. Running this command repeatedly until you see the message No snaps installed will remove all Snaps entirely.

Snap runs as a daemon (for some reason!) So, we have to stop the daemon itself (snapd.service) and the socket-based activation unit (snapd.socket)

$ sudo systemctl stop snapd.service snapd.socket
$ sudo systemctl disable snapd.service snapd.socket
$ sudo systemctl mask snapd.service snapd.socket

4. Purge Snap

The Snap daemon is installed as the snapd package. This package can be purged and held in its uninstalled state: This will ensure that the package does not get installed during auto-updates. (I think!)

$ sudo apt purge snapd -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
firefox* gnome-software-plugin-snap* snapd*
...
Removing snapd state

$ sudo apt-mark hold snapd
snapd set on hold.

5. No More Snap!

As documented in apt_preferences(5), we can set a preference in Apt which will prevent the installation of the snapd package from any release source. This will ensure that other packages which depend on snapd can not be installed using apt.

For instance, the firefox package in the Ubuntu archives is a transitional package which installs the Firefox Snap! It does not install Firefox using a Deb archive, as one would expect.

sudo cat <<EOF | sudo tee /etc/apt/preferences.d/nosnap.pref
Package: snapd
Pin: release a=*
Pin-Priority: -10
EOF

Reference: Source

Once this preferences file is in place, apt install -y firefox will fail. You are left with a system that has no web browser. The immediate next step should be to install a Web browser, by any possible method.

Start Using Flatpak

1. Setup

Set Up Flathub - Flathub

Flatpak gets around the messiest part of using any software on Linux: Setup! Their setup page is straight forward and updated! I really like this particular note on the Ubuntu-specific setup page:

Note: Ubuntu distributes GNOME Software as a Snap in versions 20.04 to 23.04, and replaced it with App Center in 23.10 and newer—neither of which support installing Flatpak apps. Installing the Flatpak plugin will also install a deb version of GNOME Software, resulting in two “Software” apps being installed at the same time on Ubuntu 20.04 to 23.04, and a single new “Software” app on Ubuntu 23.10 and newer.

The note is clearly written and easy to understand.

Note: This short note shows exactly what is going on: Starting in 23.10, Ubuntu wanted to lock up their ecosystem into Snaps and make it harder for users to install Flatpaks. So, they created an intentional misdirection (Now, you will have two apps on your system: App Center to install Snaps and “Software” to install Flatpaks!)

2. Install Firefox

Once all the steps on the Setup page are complete, restart your computer and start the “Software” application and install Firefox. The “Software” application helpfully shows the “source” of each app that is listed there: There are usually two options for applications which are distributed both as a .deb file and as a Flatpak.

Conclusion

Locking down software installation sources on any Linux distribution is a fool’s errand. I am using Ubuntu on my work machine because that is the only approved distribution. In my opinion, approved distributions should usually be base distributions like Debian, that are infinitely customisable, without compromising on corporate security tools such as Fleet and Falcon. However, being able to use Linux at work is itself a rare perk in software engineering. With the replacement of Snap with Flatpak, Ubuntu starts feeling a whole lot more like Debian.

  1. That’s a topic for another post altogether. 

  2. I am talking about search in the pre-LLM era, where the sources of information were still individual websites, rather than LLMs which ingest information from everywhere and respond with precise answers to every question.