How to Clean Up Old Disabled Snap Package Versions in Linux

The snap related system files are stored in the /var/lib/snapd folder and it keeps more than one version of the packages you have installed on your system. It is by design and it will take lot of your system disk space. In this article we will see how to remove all old disabled snap packages from your system and free up some of your disk space.

You can check all installed snap package versions using this command in terminal application (ctrl+alt+t).

snap list --all

And also you can check the size of that folder using below command in the terminal

sudo du -sh /var/lib/snapd

Remove all old Unused Snap Packages

Open the text editor application and copy paste the below code and save as in your Downloads folder.

# Removes old revisions of snaps
set -eu
snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
snap remove "$snapname" --revision="$revision"

Note: This is a bash script written by Alan Pope

Now open the terminal app and run below commands one by one.

cd Downloads

Downloads is the script location.

Also Read:  Daikhan Media Player

Now run the script using this command.

sudo bash

That’s it. Now you can check the disk size again using

sudo du -sh /var/lib/snapd


If you liked this article, please subscribe to our YouTube Channel. You can also stay connected with us on X (Twitter) and Facebook.

Leave a Reply