Rain WikiWindows · Linux · Android

APT package cache (apt clean and autoclean)

System folderDebian, UbuntuSafe to delete: Yes

The APT package cache is the folder /var/cache/apt/archives, where apt and apt-get keep downloaded .deb package files on Debian, Ubuntu and related distributions. apt-get clean removes all cached packages, apt-get autoclean removes only those that can no longer be downloaded, and apt autoremove removes packages that nothing needs any more.

1What each command does

clean removes everything except the lock file from /var/cache/apt/archives and its partial folder. The packages remain installed; only the downloaded copies go.

autoclean deletes cached package files that are no longer available in the repositories, which keeps the cache from growing forever.

autoremove uninstalls packages that were installed automatically as dependencies and are no longer required, such as old kernels on Ubuntu.

2Seeing the size

du -sh /var/cache/apt/archives shows how much space the cache uses.

How to clean the APT cache

  1. Check the size: du -sh /var/cache/apt/archives
  2. Remove all cached packages: sudo apt-get clean
  3. Review what would be removed: apt-get -s autoremove
  4. If the list looks right: sudo apt autoremove

Cautions

  • Read the autoremove list before confirming: a package you use can be listed if it was installed only as a dependency.
  • Keep at least one older kernel you know boots.

Sources

  1. apt-get(8) (Debian) manpages.debian.org
  2. apt(8) (Debian) manpages.debian.org

Last reviewed: