Rain WikiWindows · Linux · Android

apt autoremove

Command-line toolDebian, UbuntuSafe to delete: Partly

apt autoremove removes packages that were installed automatically as dependencies of other packages and are no longer needed by any installed package. On Debian and Ubuntu it frees space after programs are removed and after kernel updates, when older kernel packages are no longer required.

1Manual and automatic packages

APT marks every package as manually installed (you asked for it) or automatically installed (pulled in as a dependency). When nothing depends on an automatic package any more, apt lists it as 'no longer required'. apt-mark showmanual and apt-mark showauto show the two groups.

2Old kernels

On Ubuntu, older kernel packages become removable after newer kernels are installed. The running kernel and the newest ones are kept, so a fallback kernel remains in the boot menu.

3Keeping a package

If autoremove lists a package you use, sudo apt-mark manual <package> marks it as manually installed and autoremove will keep it.

How to use autoremove safely

  1. Preview what would be removed: apt-get -s autoremove
  2. Read the list; mark anything you use as manual: sudo apt-mark manual <package>
  3. Remove the rest: sudo apt autoremove
  4. To also delete their configuration files: sudo apt autoremove --purge

Cautions

  • Removing a package you installed by hand as a dependency can break scripts that use it; check the list first.
  • Do not remove the running kernel; uname -r shows which one it is.

Sources

  1. apt-get(8) manual page (Ubuntu) manpages.ubuntu.com
  2. apt-mark(8) manual page (Debian) manpages.debian.org

Note: RainServer offers monitoring and safe cleanup for Linux servers; it shows what will change and asks first.

Last reviewed: