APT Cache Calculator
Estimate /var/cache/apt/archives usage and the disk space `apt clean`/`apt autoclean` would recover.
Inputs
Removed by apt autoclean; apt clean removes all cached .deb files
Total Cache Size (/var/cache/apt/archives)
720 MB
`apt clean` Recovers
720 MB
`apt autoclean` Recovers (Obsolete Only)
252 MB
Obsolete .deb Files
42
Step by step
Values used
Cached .deb Files = 120; Avg .deb File Size (MB) = 6; Fraction Obsolete (Superseded Versions, %) = 35
Cache size
cache_size = cached_deb_count × avg_deb_size; autoclean_savings = obsolete_deb_count × avg_deb_size
Total Cache Size (/var/cache/apt/archives)
= 720 MB
`apt clean` Recovers
= 720 MB
`apt autoclean` Recovers (Obsolete Only)
= 252 MB
Obsolete .deb Files
= 42
How it works
APT keeps every downloaded .deb package file in /var/cache/apt/archives/ after installation, in case a reinstall is needed without re-downloading. Over time, as packages are upgraded, older versions' .deb files accumulate uselessly since only the latest installed version can ever be reinstalled from cache. `apt autoclean` removes only those obsolete, superseded package files, while `apt clean` (or `apt-get clean`) removes the entire cache indiscriminately, trading the ability to reinstall the currently-installed versions offline for maximum space recovery.
Formula
Cache size
cache_size = cached_deb_count × avg_deb_size; autoclean_savings = obsolete_deb_count × avg_deb_size
Frequently Asked Questions
What's the difference between `apt clean` and `apt autoclean`?
`apt autoclean` removes only .deb files for package versions that are no longer installable (superseded by a newer version already applied), keeping the cache for currently-installed versions. `apt clean` deletes the entire archive cache regardless of whether packages are still installed, maximizing space recovery at the cost of needing to re-download for any future reinstall.
How do I check current APT cache size without cleaning it?
`du -sh /var/cache/apt/archives` shows total size directly; `apt-get clean -s` (simulate/dry-run) or `du -sh /var/cache/apt/archives/*.deb | tail -1` in some shells can approximate what would be freed without actually deleting anything.
Is it safe to run `apt clean` on a production server?
Generally yes — it only removes cached downloaded package files, not installed packages or their configuration, so system functionality is unaffected. The only downside is that reinstalling or downgrading a package afterward requires re-downloading it rather than pulling from local cache.