How to Actually Free Disk Space on Linux
(Without Guessing or Breaking Things)
How to Actually Free Disk Space on Linux
(Without Guessing or Breaking Things)

When a Linux system runs out of disk space, the instinct is to delete old kernels and hope for the best. This sometimes works. Often, it does nothing. At that point, frustration sets in and people start eyeing /usr like it personally betrayed them.
This guide explains how to free disk space correctly, using measurement instead of superstition, and why Linux tends to look innocent while quietly hoarding gigabytes in the background.

How Linux be acting while your space running out:
Confirm Kernel Reality (Don’t blame the wrong thing)
Start by checking which kernel images are actually installed
dpkg --get-selections | grep linux-image
Entries marked deinstall look scary but take up zero disk space. They are basically ghosts. Only kernels marked install matter.
Best practice:
- Keep the current kernel
- Keep one previous kernel as a safety net
- Delete everything else, not out of anger, but discipline
Then run
sudo apt autoremove --purge
If the disk is still full, the kernel is innocent. Move on.
Measure First, Judge Later
Linux does not hide disk usage. It just refuses to summarize it for you. Run a clean top-level scan:
sudo du -xh --exclude=/proc --exclude=/sys --exclude=/run --exclude=/tmp -d1 / | sort -h
This immediately shows where space is going. In most cases, three directories stand out:
/home— your files and questionable downloads/usr— system packages doing their job/var— where background services quietly accumulate stuff
When /var is large, you are not “running out of space.” You are running unattended services.
Open /var and Let It Confess
sudo du -xh -d1 /var | sort -h
If /var/lib dominates, congratulations! you’ve found the stash. /var/lib is where well-meaning tools keep data forever, just in case you change your mind in six months.
Go deeper:
sudo du -xh -d1 /var/lib | sort -h
At this point, the filesystem stops being subtle.
Identify the Professional Hoarders
These directories almost always top the list:
/var/lib/snapd/var/lib/flatpak/var/lib/docker
None of them are bugs. All of them assume disk space is infinite and you are emotionally attached to old versions. They are wrong.
Clean Snap (It Will Resist)
Snap keeps multiple revisions of each app for rollback. That’s responsible. It’s also expensive. List everything:
snap list --all
Disabled revisions are inactive and safe to remove. Clean them automatically:
for snap in $(snap list --all | awk '/disabled/{print $1, $3}'); do
sudo snap remove $snap
done
Active snaps remain untouched. Disk space breathes again.
Clean Flatpak (It Pretends to Be Minimal)
Flatpak keeps unused runtimes and caches because one day you might reinstall something. Remove what isn’t used:
flatpak uninstall --unused
Clear the cache:
rm -rf ~/.cache/flatpak
Flatpak becomes significantly smaller and slightly less smug.
Clean Docker (It Never Forgets)
Docker treats disk space like a historical archive. Check usage:
docker system df
Remove unused artifacts
docker system prune -a
Active containers survive. Everything else is finally allowed to rest.
Principles Worth Remembering
- Disk cleanup works top-down, not by deleting random folders
dutells the truth even when it’s inconvenient- Package managers optimize for safety, not minimalism
- If you use Snap, Flatpak, or Docker, cleanup is maintenance, not an emergency task
Final Thought
When Linux says the disk is full, it’s not being dramatic. It’s being literal. The system rarely wastes space, it stores it carefully and never throws it away unless you explicitly say so.
Learn to follow the numbers, and disk space stops being a mystery and starts behaving like a resource you actually control.
Stay Tuned. Connect with me on Linkedin: https://www.linkedin.com/in/vidun-pallegoda/
메타데이터
- post_id
- c7d4381a3c3e
- slug
- how-to-actually-free-disk-space-on-linux-without-guessing-or-breaking-things-c7d4381a3c3e
- url
- https://medium.com/@vinethdina77/how-to-actually-free-disk-space-on-linux-without-guessing-or-breaking-things-c7d4381a3c3e
- canonical_url
- https://medium.com/@vinethdina77/how-to-actually-free-disk-space-on-linux-without-guessing-or-breaking-things-c7d4381a3c3e
- author_url
- https://medium.com/@vinethdina77
- status
- ok
- fetched_at
- 2026-07-13 15:51:14