Ubuntu is distributing more applications as the universal Snap package, but some users don’t like them. So I’m writing this tutorial for those want to completely get rid of Snap and prevent it from being installed back.
NOTE 1: Before getting started, please backup your app data, e.g., Firefox bookmarks. Attention that Ubuntu Software and App Center will also be removed after following this tutorial.
NOTE 2: This tutorial is tested and works in Ubuntu 22.04 and Ubuntu 24.04. It should also work on official flavors, e.g, XUbuntu, KUbuntu, etc.
Step 1. Remove Snap apps and the Daemon
Press Ctrl+Alt+T on keyboard to open a terminal window. When it opens, run the commands below one by one.
1.) List all installed snap applications:
snap list
They are by default Snap Store (Ubuntu Software), Firefox, default theme, and few core packages.
2.) Remove the apps one by one, Firefox and Snap-store go first, then theme package, gnome platform (in sandbox), and finally base packages and snapd daemon. NOTE: the package names may vary depends on “snap list” output.
sudo snap remove --purge firefox
sudo snap remove --purge snap-store
sudo snap remove --purge gnome-3-38-2004
Also run snap remove
command to remove “gtk-common-themes”, “snapd-desktop-integration”, “bare”, “core20”, and finally “snapd”.
3.) Finally remove the Snap daemon package via apt:
sudo apt remove --autoremove snapd
Step 2. Block Snap package
After completely removed snap packages, you may prevent Ubuntu from installing them back by settings low priority for the Snapd
package. Here’s how to do the trick inspired by the way Linux Mint 20 did.
1.) Press Ctrl+Alt+T on keyboard to open terminal. When it opens, run the command below to create and open a configuration file:
sudo gedit /etc/apt/preferences.d/nosnap.pref
For Ubuntu 24.04, replace gedit
with gnome-text-editor
. For non-GNOME desktop, use your system text editor or nano
(Ctrl+S to save, and Ctrl+X to exit) that works for all.
When the file opens, paste lines below to tell refuse snapd
from any repository:
# To prevent repository packages from triggering the installation of snap,
# this file forbids snapd from being installed by APT.Package: snapd
Pin: release a=*
Pin-Priority: -10
2. After save the file, refresh package cache via command:
sudo apt update
Now, whenever you try to installed a Snap package or the daemon, it outputs either unmet dependencies (snapd) or package has no installation candidate.
How to Restore:
If you change your mind, run the commands below at any time will install back the Snap apps.
Firstly, run command in terminal (Ctrl+Alt+T) to unblock the daemon:
sudo rm /etc/apt/preferences.d/nosnap.pref
Then, install Ubuntu Software via command:
sudo snap install snap-store
And install Firefox as snap if you want by running command:
sudo apt install firefox
Thanks for this. All OK but one small error for us copy and paste enthusiasts. In Step 1 para 2.) should be “snapd-desktop-integration”
Updated. Thanks bill!
Thank you for this, got rid of all the extra bits that seemed to still be there after running Popeys script
Also remove redundant folders if there are any left:
rm -rf ~/snap
sudo rm -rf /snap /var/snap /var/lib/snapd /var/cache/snapd /usr/lib/snapd
Thanks!
I could not delete /snap
Says it’s a read-only file system.
root@Whizz:/# sudo rm -rf /snap
Results a bunch of lines on the form:
rm: cannot remove ‘snap/bare/5/var/tmp’: Read-only file system
Has Ubuntu blocked snap removal somehow? If I can’t get rid of snap, I’ll go to another dstro.
Worked great thanks for the posting.
Thank you man! very useful!
Big thanks!
thank you! Almost done, but leave the text file nosnap.pref not be saved. I canceal it.
Apparently, this leaves AppArmor a little discontent with the missing snap profile dependencies…
In my case, AppArmour FAILS to load. It’s complaining about the missing “/var/lib/snapd/apparmor/snap-confine” refered to in the profile “/etc/apparmor.d/usr.lib.snapd.snap-confine.real” at line 11…
Furthermore, can’t disable the profile because “ERROR: Include file /var/lib/snapd/apparmor/snap-confine not found”
… Nice solution, but a bit touchy !
Solved.
It’s necessary to purge snapd when removing, so run the auatoremove, then run this:
sudo apt purge snapd
Then, get apparmor to clean up its profiles:
sudo aa-remove-unknown
Now Apparmor can be reloaded without problems.
You can see that AppArmor failed using the following command:
systemctl status apparmor
oops…never mind. I missed a step.
Please feel free to delete my post.
this worked perfectly for me on ubuntu mate 24.04. many thanks. very followable. :)
What about desktop-bootstrap and firmware-updater do those get removed as well? There are 12 Snaps in a fresh install is it safe to remove them ?
Thsi is xUbuntu’s fresh install and probably applies to all the flavours does it remove all the Snaps?
https://snipboard.io/wLOByQ.jpg
Yes, it will all the snaps.