Remove Snap Ubuntu 22.04 LTS

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).

 

Update: A member of our community forums suggested the following:
“…you could also switch to Pop!_OS instead. They’ve already removed Snap and gone with Flatpak.”

This is an option. Also, see Best Linux Distros for Beginner, Experienced and Expert users. However, swapping distros isn’t an option if you prefer to stick with Ubuntu. So you must either keep Snap, remove it, disable it, or replace it. Also, don’t forget another alternative, which is Appimage.

 

Why remove Snap from Ubuntu?

Remember when 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 hard-coded to use Canonical’s servers to fetch snaps and all associated metadata. 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.

Not too long ago, 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.

While Snap has some advantages, do they outweigh the disadvantages? It may not matter because Snap does seem like it’s here to stay.

 

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

Oct 1st, 2023 update: I tried to remove Snap from a Ubuntu 22.04 LTS VM today. But it’s also removing ubuntu-server-minimal. So, instead of removing, I disabled it completely like this:

sudo systemctl disable snapd.service
sudo systemctl disable snapd.socket
sudo systemctl disable snapd.seeded.service
sudo systemctl mask snapd.service

Disabling Snap instead of uninstalling it can be a practical choice for several reasons:

  1. Preserve System Functionality: Disabling Snap allows you to keep the functionality of your Ubuntu system intact. Some essential software and system components, such as Firefox and the Ubuntu Software store, are installed via Snap by default. If you uninstall Snap, you might lose access to these applications without straightforward alternatives.
  2. Maintains Compatibility: Snap packages ensure compatibility and ease of distribution. Removing Snap might lead to compatibility issues with certain applications or services that rely on it. Disabling Snap keeps these dependencies in place, preventing potential disruptions.
  3. Easier Reversion: In the future, if you change your mind or encounter situations where you need Snap again, re-enabling it is a more straightforward process than reinstalling it from scratch. Disabling allows you to switch back to using Snap without much hassle.
  4. Minimal System Impact: Disabling Snap doesn’t occupy much disk space or system resources, so it doesn’t significantly affect system performance or resource usage. You can choose to keep it disabled until you have a specific need for it.
  5. Preserve User Preferences: If you’re not ideologically opposed to Snap and don’t have strong reasons to remove it, disabling it respects user preferences. Some users may prefer to keep Snap for specific applications while using other package formats for different purposes.

 

Original Snap removal method

Remove Snap Ubuntu 22.04 LTS

First, let’s list all the snaps installed on your system with the following command:

snap list

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:

vim /etc/apt/preferences.d/firefox-no-snap

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

 

Conclusion

Update: Disabling Snap instead of uninstalling it provides a balanced approach that maintains system functionality and compatibility while allowing users to re-enable it when needed easily. It’s a pragmatic choice that ensures you have flexibility in managing software on your Ubuntu system.

That said, the decision to remove Snap and its associated packages from Ubuntu 22.04 LTS is driven by individual preferences and considerations. While Snap packages offer some advantages, such as easy distribution and sandboxing, there are also concerns related to transparency and security.

Snap relies on Canonical’s servers for fetching snaps and metadata, and the code for these backend servers is not open source. This lack of transparency has led some users to opt for alternatives or to remove (or disable) Snap altogether.

Before uninstalling Snap, it’s essential to understand the potential consequences. Removing Snap means losing access to software installed via Snap packages. However, alternatives like Flatpak can provide containerized software solutions.

Additionally, some Ubuntu-specific software, such as Firefox, Ubuntu Software Store, and others, are installed via Snap by default, and there may not be direct deb package alternatives for them. Users should weigh the importance of these applications in their decisions.

In the end, the hope remains that Ubuntu will provide an official, user-friendly option to opt-out or a Snap uninstall option, similar to the flatpak uninstall command. Until then, users have the flexibility to make choices that align with their preferences and needs in managing software packages on their Ubuntu systems. For further assistance, you may explore tools like unsnap to simplify the removal of Snap packages.

 

Published: April 28th, 2022 | Last Updated: October 1st, 2023.

Tags: , ,

Discussion

  1. When you say containerized features, is that related to the docker engine by any chance?

  2. No referring to a method of distributing software in this particular case.

  3. Does it impact the overall OS functionality? I have snap on my Ubuntu I’ve been considering removing it.



Top ↑