Ubuntu is a great distro. It's stable, popular, backed by computer makers and most importantly it's one of the most software-wise supported Linux distro.
But it's also the distro that Canonical pushes Snaps. Which is a proprietary packaging format also made by Canonical.
Snaps are actually great for servers. Even I currently run my Mastodon server as a snap.
But for desktops, snap packages tends to be slow and take a lot of storage space.
Also it's server-side is closed-sourced and people have concerns about their privacy.
They aren't the ideal packaging solution for desktop use case when compared to Flatpaks, AppImages or even native packages.
So in this post, I'm going to show you how to remove Snaps from your freshly installed Ubuntu desktop and replace it with Flatpaks. Let's get started!
1. Add Firefox PPA
Before going any further, we need to add Mozilla's official PPA to our system to prevent triggering installation of snap when we try to install Firefox.
We first need to remove the snap version of Firefox. If you're currently following this tutorial from Ubuntu, make sure to note those commands somewhere you can read before continuing.
To remove Firefox from snap run the command
sudo snap remove --purge firefox
Than we'll install Mozilla's apt repo key
wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- | sudo tee /etc/apt/keyrings/packages.mozilla.org.asc > /dev/null
Getting no output from this command means it ran with no problem. Now we can add the APT repo to our sources.list
file.
echo "deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" | sudo tee -a /etc/apt/sources.list.d/mozilla.list
After that we need to set the Firefox package priority to ensure that package from Mozilla is always preferred. Otherwise when we try to install Firefox, it'll be installed from Snap. Which we're trying to avoid.
echo '
Package: *
Pin: origin packages.mozilla.org
Pin-Priority: 1000
Package: firefox*
Pin: release o=Ubuntu
Pin-Priority: -1' | sudo tee /etc/apt/preferences.d/mozilla
Now we can install Firefox from Mozilla's repo.
sudo apt update && sudo apt install firefox
And now when you launch Firefox you can check to see it's from the Mozilla's Debian repo.
2. Removing Snap
Now we need to remove all the snaps we've installed and remove the snapd from our system.
Before removing snap, we need to stop it's systemd service.
sudo systemctl disable --now snapd && sudo systemctl disable --now snapd.socket
After that we can remove snapd from system with command below.
sudo apt purge snapd
At that point make sure to use the purge command instead of autoremove, otherwise all the mounts and stuff installed by snap will be left on our system.
3. Avoid installation of snap
As our last step, we need to add a preference file to apt to avoid installing snap. This is needed because programs like Thunderbird and Chromium-browser still triggers installation of Snap.
echo '
Package: snapd
Pin: a=*
Pin-Priority: -10 ' | sudo tee /etc/apt/preferences.d/no-snap.pref
Now when we install thunderbird again from apt, we can see it installs without snapd.
4. Flatpak and Gnome Software
I personally prefer Flatpaks over Snaps because they're much better and more user friendly.
And since removing snap also removes the Ubuntu Software Center, we'll gonna replace it with the Gnome Software application.
To install Flatpak and enable Flathub, we'll use the commands below.
sudo apt install flatpak
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
After that we'll install Gnome Software with it's plugin for Flatpak
sudo apt install gnome-software gnome-software-plugin-flatpak
And we're done!
Now we can install applications from Flathub and APT repositories using Gnome Software with no need to worry about getting slow running snap packages on our system.
Reply via E-Mail
Thank You!
22.02.2025