How to Remove Orphaned Packages and Free Up Space on Linux
With apt autoremove, including the dry-run option to preview first.
Orphaned packages are dependencies that were installed alongside a program, but that nothing uses any more after you uninstalled it — they sit there taking up space unnecessarily.
sudo apt autoremove
Automatically removes these leftover packages, safely — apt knows how to tell what's genuinely orphaned from what's still needed by another program.
Tip: run this routinely after uninstalling programs, not just when you notice you're low on space — it's a good regular maintenance habit, with no real risk.
See how much space you'd free up before confirming
sudo apt autoremove --dry-run
Shows what would be removed without actually doing it — useful for confirming before applying the change for real.
Frequently asked questions
Is it safe to run apt autoremove?
Yes, apt reliably tells apart packages that are genuinely orphaned (no longer needed by anything) from ones that are still active dependencies of another installed program.
How often should I do this?
It's good practice to run it after uninstalling programs, or periodically as general maintenance — there's no real risk in doing it frequently.