Free Space with apt autoremove and apt clean

autoremove deletes no-longer-needed dependency packages, and clean wipes the downloaded .deb cache in /var/cache/apt/archives.

LinuxdebiandiskaptMedium risk
Run `sudo apt autoremove --purge` to remove orphaned packages (and their configs), then `sudo apt clean` to empty the package cache.

01Command

Command
$ sudo apt autoremove --purge && sudo apt clean

02What it does

Read the package list autoremove prints before typing Y — if it lists something you installed on purpose, mark it manual with `sudo apt mark manual <pkg>`. `apt clean` frees the most space after big upgrades, sometimes gigabytes of cached .deb files; `apt autoclean` only removes obsolete versions if you want a gentler option. On Fedora the equivalents are `sudo dnf autoremove` and `sudo dnf clean all`.

03Risk

RiskMedium risk
RequirementsDebian/Ubuntu with apt; use `sudo dnf autoremove` and `sudo dnf clean all` on Fedora
!Warning: Check the autoremove list before confirming — old kernels appear there, and pruning them removes rescue boot options.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • apt(8) - Linux manual page
    Ubuntu Manpages · technical · 2026-09-17
    Evidence: apt autoremove removes packages that were automatically installed to satisfy dependencies and are no longer needed; apt clean clears the local repository of retrieved package files.

Last verified: 2026-09-17 · Category: System & Settings

06Related solutions