Home » #Technology » How to Safely Clean Up Disabled Snap Packages on Ubuntu

How to Safely Clean Up Disabled Snap Packages on Ubuntu

Managing disk space on a Linux server is a critical task, especially when it comes to Snap packages. By default, Snap retains multiple revisions of applications, including disabled versions that are no longer in use. Over time, these can consume a significant amount of storage — especially under /var/lib/snapd.

In this tech concept, you’ll learn how to identify and safely remove disabled Snap versions on Ubuntu, freeing up valuable disk space without disrupting running applications. For 20+ years, I’ve turned code into products and ideas into growth stories. I believe in tech’s power to transform—and I’m here to help you tap into it. Your journey starts now, and it’s full of possibility.

What Is Snap?

Snap is a modern package management system developed by Canonical, the makers of Ubuntu. Unlike traditional package managers (like APT or YUM), Snap packages are self-contained, meaning they include all dependencies needed to run an application.

This makes them portable and ensures consistent behavior across different Linux distributions. Snap also supports automatic updates, rollback to previous versions, and strict security confinement through sandboxing. While Snap simplifies app distribution and maintenance, its practice of retaining multiple versions by default can lead to unnecessary disk usage if not managed properly.

What Are Disabled Snap Versions?

Understanding Snap Package Behavior

Snap automatically keeps previous versions of packages for rollback purposes. When a package gets updated, older revisions are marked as disabled. These versions are no longer used but are not automatically removed.

For example, you might see:

$ snap list --all
Name        Version    Rev   Tracking       Publisher   Notes
core18      20250123   2857  latest/stable  canonical✓  base,disabled
core18      20250523   2889  latest/stable  canonical✓  base

In the above output, core18 revision 2857 is disabled while 2889 is active. Removing the disabled revision is safe and helps save disk space.

Why It’s Safe to Remove Disabled Snap Versions

  • Disabled packages are not in use: They’re leftovers from updates.
  • No impact on running apps: Snap packages that are actively used remain untouched.
  • Reclaiming storage: Old revisions can accumulate to hundreds of MBs over time.

Snap is designed to manage multiple revisions, but unless you need the rollback feature, it’s safe and recommended to clean them up periodically.

How to Check Snap Disk Usage

View Total Snap Size

Use this command to see total space used by Snap packages:

sudo du -sh /var/lib/snapd

Breakdown by Directory

To identify which parts of Snap are consuming the most space:

sudo du -h /var/lib/snapd --max-depth=1 | sort -hr

Check Snap Cache

Snap maintains a cache that can also be cleaned:

sudo du -sh /var/lib/snapd/cache

If it’s large, clean it up using:

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

How to List and Remove Disabled Snap Revisions

Step 1: List All Snap Packages and Revisions

snap list --all

Look for rows marked with disabled under the “Notes” column.

Step 2: Remove Disabled Revisions One by One

If you prefer to clean manually:

sudo snap remove core18 --revision=2857
sudo snap remove amazon-ssm-agent --revision=9882
sudo snap remove snapd --revision=24509

Step 3: Automatically Clean All Disabled Snap Versions

Run this one-liner to remove all disabled Snap revisions:

snap list --all | awk '/disabled/{print $1, $3}' | while read snapname revision; do
    sudo snap remove "$snapname" --revision="$revision"
done

This script safely iterates through and removes only those packages that are marked as disabled.

What Not to Remove

  • Do not remove Snap revisions without the disabled tag unless you’re absolutely sure they’re unused.
  • Avoid deleting the entire /var/lib/snapd directory unless you are completely removing Snap from your system.

Optional: Completely Remove Snap from Ubuntu

If you’re not using any Snap applications, you can fully uninstall Snap:

sudo systemctl stop snapd
sudo apt purge snapd
sudo rm -rf ~/snap /snap /var/snap /var/lib/snapd

Be cautious: Some Ubuntu desktop components and cloud tools may rely on Snap.

My Tech Advice: Snap is a flexible package management system, but its automatic retention of old revisions can silently consume disk space. Regularly cleaning up disabled Snap packages is both safe and effective. Use the tools and scripts above to maintain a lean and optimized Ubuntu server.

By managing your Snap packages wisely, you ensure better disk usage and keep your system clean and efficient.

Optimise your server ! Try the above tech concept, or contact me for a tech advice!

#AskDushyant
Note: The names and information mentioned are based on my personal experience; however, they do not represent any formal statement.
#TechConcept #TechAdvice #Linux #Ubuntu #Server

Leave a Reply

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