Save Space On Ubuntu - “SNAP” Folder Takes Space Fix

Author SKS
Author: SKS
Published on: Jun 18, 2024
Last updated: Jul 22, 2024
blog picture

List them to see:

sudo snap list --all

Remove the old versions:

sudo snap remove <package> --revision=<old-revision>

For example in my case:

Name               Version          Rev    Tracking       Publisher      Notes
bare               1.0              5      latest/stable  canonical✓     base
certbot            2.11.0           3834   latest/stable  certbot-eff✓   classic
chromium           126.0.6478.126   2897   latest/stable  canonical✓     disabled
chromium           126.0.6478.182   2910   latest/stable  canonical✓     -
code               f1e16e1e         164    latest/stable  vscode✓        classic
code               ea1445cc         163    latest/stable  vscode✓        disabled,classic
core20             20240416         2318   latest/stable  canonical✓     base
core22             20240408         1380   latest/stable  canonical✓     base
core24             20240528         423    latest/stable  canonical✓     base
cups               2.4.9-1          1052   latest/stable  openprinting✓  disabled
cups               2.4.10-1         1058   latest/stable  openprinting✓  -
gnome-42-2204      0+git.510a601    176    latest/stable  canonical✓     -
gnome-46-2404      0+git.1f00542    42     latest/stable  canonical✓     -
gnome-46-2404      0+git.18eace2    39     latest/stable  canonical✓     disabled
gtk-common-themes  0.1-81-g442e511  1535   latest/stable  canonical✓     -
mesa-2404          24.0.5           44     latest/stable  canonical✓     -
snapd              2.63             21759  latest/stable  canonical✓     snapd

I will delete these:

sudo snap remove chromium --revision=2897
sudo snap remove code --revision=163
sudo snap remove cups --revision=1052
sudo snap remove gnome-46-2404 --revision=39

Script to Automate Removal

for snap in $(snap list --all | awk '/disabled/{print $1, $3}'); do
  sudo snap remove "$snap" --revision="$3"
done

Clean up cache:

sudo rm -rf /var/lib/snapd/cache/*

You can also use this command to check whats taking up space:

du --max-depth=1 --human-readable / | sort --human-numeric-sort

These steps should help you to reclaim disk space on your Ubuntu server by removing old and unused Snap versions!

✌️
💩
❤️‍🔥
🤔

Support me if you want!

Your support keeps me motivated to provide more helpful content. ❤️