# apt autoremove

> What apt autoremove removes, why packages become 'no longer required', and how to check the list before removing anything.

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.

## Manual 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.

## Old 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.

## Keeping 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)](https://manpages.ubuntu.com/manpages/noble/man8/apt-get.8.html)
2. [apt-mark(8) manual page (Debian)](https://manpages.debian.org/bookworm/apt/apt-mark.8.en.html)

Last reviewed: 2026-10-08
URL: https://wiki.raincleaner.eu/linux/apt-autoremove
