APT Cache Calculator
Calculate disk space consumed by the APT package cache and downloaded .deb archives.
About APT Cache Calculator
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
Worked example
With the default values below, APT Cache Calculator returns Total Cache Size (/var/cache/apt/archives) of 720 MB. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Cached .deb Filesminimum 0
- 120
- Avg .deb File Size (MB)minimum 0.1
- 6
- Fraction Obsolete (Superseded Versions, %)accepts 0–100
- 35
Results
- 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
- 1Values used
- 2Cache size
- 3Total Cache Size (/var/cache/apt/archives)= 720 MB
- 4`apt clean` Recovers= 720 MB
- 5`apt autoclean` Recovers (Obsolete Only)= 252 MB
- 6Obsolete .deb Files= 42
Assumptions and limits
- The result is derived only from the 3 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to whole numbers, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
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.
