How to Recover Space When the Disk Is Full on Linux
Package cache, orphans, trash and logs, without touching personal files.
- Identify what's taking up the most space
with
du -sh /* 2>/dev/null | sort -rh | head -10. - Clean the package cache
with
sudo apt clean. - Remove orphaned packages
with
sudo apt autoremove. - Empty the trash:
rm -rf ~/.local/share/Trash/*. - Check and clean old logs in
/var/logif they're very large.
Warning: before deleting anything in
/var/log manually, confirm you don't need those logs to
diagnose some recent problem — when in doubt, compress instead of
deleting.
Tip: combine these steps in this order — they usually resolve most full-disk cases without needing to delete personal files.
Frequently asked questions
Is it safe to delete files in /var/log?
With care — confirm you don't need those logs to diagnose a recent problem. It's safer to compress them than delete them directly if you have doubts.
Do these steps affect my personal files?
No, they focus on system cache, orphaned packages, and trash — your documents and personal files aren't affected by any of these steps.