- How do I remove all snaps and snapd, preferably with a single command [duplicate]
- 2 Answers 2
- How to remove a snap package on Ubuntu
- What is Snap Package
- How to Remove a Snap Package on Ubuntu
- Conclusion
- About the author
- Prateek Jangid
- Remove Snap Ubuntu 22.04 LTS
- Why remove Snap from Ubuntu?
- Before uninstalling Snap from Ubuntu
- How to remove Snap from Ubuntu 22.04 LTS
- Conclusion
How do I remove all snaps and snapd, preferably with a single command [duplicate]
I’m currently using a Ubuntu 20.04 machine with a small root volume. The default snap setup occupies ~1G space, though with only a few packages. And when I tried to remove core from snap I got the following error.
# snap remove core18 error: cannot remove "core18": snap "core18" is not removable: snap is being used by snaps gnome-3-34-1804, gtk-common-themes and snap-store.
I understand I can work around the issue by manually remove the dependants first, but is there a one-liner solution that manages the dependencies automatically so that all snaps and snapd can be removed in one go?
So the design philosophy of snap is to make every package as independent and self-contained as possible? Interesting. But what about stuff like core18 and snap-store ? Are they somewhat base/root package needed by all other packages?
That all starts to make sense now. But just one last question, is there an official command to automatically remove all snap installed packages and snapd as well? I happen to have a small root volume and want to safely clear up /var/lib/snapd directory.
@vanadium That answer fails at the first line of snap list ‘s output, which is actually a header line rather than packages. This is easy to fix, though. But what is hard is the dependencies (though there is very few) requires packages to be removed in a specific order, which that answer fails to address as well.
2 Answers 2
A one-liner this is not but, if you would like to completely remove everything related to snaps on your machine, follow these steps:
- Open the Terminal
- List all the snaps installed on your system with snap list . You will see something like this:
Name Version Rev Tracking Publisher Notes chromium 87.0.4280.141 1444 latest/stable canonical✓ - core 16-2.48.2 10583 latest/stable canonical✓ core core18 20201210 1944 latest/stable canonical✓ base emote 1.3.0 12 latest/stable tom-james-watson - gnome-3-28-1804 3.28.0-19-g98f9e67.98f9e67 145 latest/stable canonical✓ - gnome-3-34-1804 0+git.3556cb3 66 latest/stable canonical✓ - gnome-system-monitor 3.36.0-12-g35f88a56d7 148 latest/stable/… canonical✓ - gtk-common-themes 0.1-50-gf7627e4 1514 latest/stable/… canonical✓ - snap-store 3.38.0-59-g494f078 518 latest/stable/… canonical✓ - spotify 1.1.46.916.g416cacf1 43 latest/stable spotify✓ - vlc 3.0.11 1700 latest/stable videolan✓ -
sudo snap remove chromium sudo snap remove emote sudo snap remove spotify sudo snap remove vlc
sudo snap remove snap-store sudo snap remove gtk-common-themes sudo snap remove gnome-system-monitor sudo snap remove gnome-3-34-1804 sudo snap remove gnome-3-28-1804 sudo snap remove core18 sudo snap remove snapd
No snaps are installed yet. Try 'snap install hello-world'.
rm -rf ~/snap sudo rm -rf /snap sudo rm -rf /var/snap sudo rm -rf /var/lib/snapd
Your system will now be devoid of snaps.
How to remove a snap package on Ubuntu
Snap packages are used in Linux distributions to offer multiple options like installing, deploying, and removing software. Snap package is beneficial for developers to use the newest versions of apps on their Linux machine. Snap is a better alternative of apt. And many users prefer it for their system. Ubuntu and Canonical also consider it as one of the best installation repositories and package management tools for Linux. As per the consideration of advantages, Snap offers:
- Snap apps work in the sandbox environment.
- Snap repository has many applications from popular publishers such as Google, KDE, and Microsoft.
- All snap packages are completely auto-updated
- There is no additional installation required because dependencies are bundled in a snap package.
You can easily install and Use Ubuntu snap packages without having any trouble. Sometimes people want to remove a snap package, but they don’t know how to do it. So, if you are one of them, then please read our article to learn the easiest way to remove a snap package on Ubuntu(we are considering this Linux distro because it is the most commonly used operating system and the command line for removing a snap package is almost the same for every Linux distribution). However, before understanding the removal procedure of a snap package, let’s discuss some important information about snap packages.
What is Snap Package
Users can install the application in Linux using multiple methods, and source codes are one way to install different applications. In this case, “package” comes into the picture, so it is a software package created by developers after developing a program so that users can easily install it. That’s why .deb or Debian software packaging became popular, but it requires a little bit more effort for software installation. Therefore, the .snap package was created for the Ubuntu core system as it consists of all dependencies. These snap packages also have benefits compared to .deb dependency handling because anyone can easily use snap packages in their system.
How to Remove a Snap Package on Ubuntu
We will now cover the step-by-step procedure of removing a snap package easily, so let’s consider that you have OBS Studio from the system.
First, open the Linux terminal and run the following command in it:
The basic command line to remove a snap package is sudo snap remove . You have to put the name of a specific application instead of .
Once you execute the command successfully, the terminal will ask you to enter the [sudo] password you put for the installation, but if you don’t have any password, press Enter to process it.
After completion of this procedure, you will see that OBS studio gets uninstalled from the system. However, the folder of OBS is still present in the snap folder, so execute the following command to remove it:
As you can see in the image below, the command has removed the additional folder related to the uninstalled snap package.
Note: This procedure is appropriate for the older versions of Ubuntu, such as 18.04, 16.04, etc.
Conclusion
That’s it, and you are done, so this is how you can remove a snap package in Ubuntu easily. It is the most straightforward procedure for removing any snap package, and you can use it in the different versions of Ubuntu. We also mentioned complete details on snap packages and their benefits. However, we didn’t include the process of using a snap package because there is a comprehensive article on our website, so make sure to read it. This article also has a procedure to remove the additional folder after the uninstallation so that you don’t have to do it manually.
About the author
Prateek Jangid
A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.
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 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?
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 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.
While snap has some advantages, do they outway 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
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:
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:
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.
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
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
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.