I needed to find how to remove snap and all those packages from my vintage Ubuntu laptop. It all started after trying to boot up and getting the ‘frozen’ Ubuntu logo at boot time. After brewing a nice Catimor coffee at home I discovered there was little storage space left. Why!?? My laptop was turned off for more than four months.

I got the below error when I was able to login using the recovery Terminal. I tried running apt update and got 'No space left on device'.

Then I ran sudo du -sh | sort -hr to find out what was taking storage space in Linux. I was surprised about what I found. WTF! is that ‘snap’ folder taking 8.5G!?

I had to take a walk by the nice waterfront in NYC before taking on this one. After I came back I found how to remove snap from Ubuntu. BTW, Snap or Snaps are self-contained apps bundling all libraries, and they keep old versions (revisions) for rollbacks by default. No good for my case!

How to remove snap completely from Ubuntu

I’m going to list the simple commands in order below. First, run the below snap command to view the snap packages installed in Ubuntu:

snap list -all

I did not find a way to remove all at once. So, you will need to remove them one by one. Using the below snap command:

sudo snap remove <package_name>

After you remove all snap packages stop the snap service:

sudo systemctl stop snapd

Then disable it:

sudo systemctl disable snapd

After ‘mask’ it to avoid it to get started by anything other service:

sudo systemctl mask snapd

Next, purge snapd:

sudo apt purge snapd -y

Then, mark on ‘hold’ it to avoid any future updates by the apt package manager:

sudo apt-mark hold snapd

Delete the snap package directories to re-claim disk space:

sudo rm -rf ~/snap/
sudo rm -rf /snap
sudo rm -rf /var/snap
sudo rm -rf /var/lib/snapd

Then, prevent snap from re-installing at all. Create a new file under

/etc/apt/preferences.d/nosnap.pref

Use your favorite text editor. I use vim. Add the below text to the file:

Package: snapd
Pin: release a=*
Pin-Priority: -10

Update the apt source list:

sudo apt update

That is all! Enjoy Ubuntu without snap. I suggest to install software using apt or from source.

Leave a comment

Your email address will not be published. Required fields are marked *