97

How do I remove snap? apt pretends it's not there but I can still call commands with it.

Trying to rm it says "read only file system"

root@tunnel:/# apt remove snap
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'snap' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@tunnel:/# snap whoami
email: -
0
122

The package is not called snap, but instead is snapd.

You will want to do

sudo apt autoremove --purge snapd
8
  • 1
    Why --purge? The OP didn't say the removal must also remove the configs. – Ruslan May 14 '18 at 10:44
  • 17
    @Ruslan If the configs are left, apparmor crashes on startup in this case. – Charles Green Feb 22 '19 at 20:52
  • 1
    Will this prevent future system updates? Oftentimes the ubuntu-desktop meta-package gets deleted for things like this and you are forced to re-install it later on if you want to upgrade. Will that be the case here? – tutuca Nov 17 '19 at 3:26
  • 1
    Removal of a metapackage does not prevent updating of packages which it originally installed, no. – dobey Nov 17 '19 at 15:41
  • 1
    @pietro This is not for removing individual snaps, but to remove all snaps and support thereof, from the system. If you want to remove individual snaps, you need to do so with snap remove instead. – dobey Mar 6 '20 at 15:35
76

TL;DR:

sudo rm -rf /var/cache/snapd/

sudo apt autoremove --purge snapd gnome-software-plugin-snap

rm -fr ~/snap

This will completely remove snap, snapd, all installed snap packages and their data, and never again suggest snap packages in the software store.

Your output of mount, df and cat /proc/partitions will thank you ;)

8
  • 10
    My output of mount, df and cat /proc/partitions thanks you :) – Maarten Feb 26 '19 at 11:18
  • This does not work: rm: cannot remove '/snap/lxd/10343/zfs-0.8/lib/libzpool.so.2.0.0': Read-only file system -- for example. – Zelphir Kaltstahl Mar 25 '19 at 11:16
  • 2
    Perhaps in your case you need to gracefully uninstall all snaps before removing snapd itself -- and not just brutally rip it out like I did. A combination of sudo snap list, a loop, and sudo snap remove $package should do it, but I don't have snap installed, so unfortunately I cannot get more concrete that this =\ – Stephan Henningsen Mar 27 '19 at 8:39
  • 1
    My FAT has just gone on a diet. – Owl Oct 10 '19 at 15:35
  • 1
    In my case, the sudo rm -rf /var/cache/snapd/ was not needed, as --purge did cleanup that directory – machineaddict Jan 10 '20 at 16:34
12

I'm not sure if you asked espacially for this, but if you just want to remove showing snap packages in Software (gnome-software; as I wanted to), you can just uninstall snap plugin with command sudo apt-get remove --purge gnome-software-plugin-snap.
I don't know if --purge is necessary, but it works fine - Software doesn't show now packages from Snap Store, but I can still install them by commandline with snap install [something]

0
0

if you want to remove snap store then you have to execute the following command in terminal:

sudo apt autoremove snapd
1
  • 3
    This is very similar to dobey's answer. The difference is that conffiles are removed when --purge is passed (as in that answer), but not when the autoremove action is used without --purge (as in this answer). So this is not the same as that answer, but if there's a particular reason you recommend keeping them (even if it is that their removal is typically unnecessary) then you may want to edit this to explain that. – Eliah Kagan Jun 24 '20 at 16:43
0

I have just installed a server and apparently it also comes pre-installed with snaps that besides being useless are also blocking the shutdown of the device.

Here is a very good article with instruction for cleaning up your system: https://www.kevin-custer.com/blog/disabling-snaps-in-ubuntu-20-04/

It basically says:

do snap list
snap remove all items (by dependency order)
apt purge snapd
clear various files at /home/*/snap, /usr/lib/snap and alike

In case of the server the only snap was lxd - something Canonical is pushing as an alternative to docker.

IMHO this a bit of a conflict of interests between Canonical and the users. Users should be able to opt-in whatever they need and not be forced to uninstall stuff the hard way..

In any case, at least for the moment this is reversible. You can remove specific packages and the snap daemon and install later if needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.