How to Free Up Disk Space on Linux
"No space left on device" almost never means you genuinely filled the disk with your own files. On Linux it's usually package caches, old kernels, oversized logs and forgotten downloads. Here's how to find the real culprit and reclaim it safely, no guesswork, nothing that breaks your system.
First: find what's actually using the space
Don't delete anything blind. Start by measuring. These three commands tell you almost everything:
df -h # how full is each disk/partition?
du -sh ~/* | sort -h # biggest things in your home folder
du -sh /var/* 2>/dev/null | sort -h # biggest things under /var
If you have it, ncdu is even better, an interactive, navigable map of what's eating your disk. Install it with sudo apt install ncdu (or dnf), then run ncdu / and browse.
Clean the package manager cache
Every package you install leaves a downloaded archive behind. Over a year that adds up to gigabytes you never need again.
# Debian / Ubuntu / Mint
sudo apt clean
sudo apt autoremove --purge # also removes unused dependencies
# Fedora
sudo dnf clean all
sudo dnf autoremove
# Arch
sudo pacman -Sc
Remove old kernels
Your system keeps a few old kernels so you can boot if an update goes wrong, but it can hoard more than you need, and each one is hundreds of megabytes in /boot. On Ubuntu/Debian, sudo apt autoremove --purge usually clears the surplus. Keep at least your current kernel and one previous as a fallback.
Trim the logs
Systemd's journal can quietly grow to gigabytes. Cap it without losing recent history:
journalctl --disk-usage # see how big it is
sudo journalctl --vacuum-time=2weeks # keep only the last 2 weeks
sudo journalctl --vacuum-size=200M # or cap it at 200 MB
Hunt down the big, forgotten files
# Files over 500 MB anywhere under your home
find ~ -type f -size +500M -exec ls -lh {} \; 2>/dev/null
# The usual suspects
du -sh ~/.cache # app caches, safe to clear
du -sh ~/Downloads # old installers and ISOs
Browser caches, old virtual-machine disk images, Docker layers (docker system prune) and language package caches (npm, pip) are the most common space hogs on a developer's machine.
The 30-second routine
Once you know your system, a quick monthly clean keeps things healthy:
sudo apt clean && sudo apt autoremove --purge
sudo journalctl --vacuum-time=2weeks
rm -rf ~/.cache/*
That's it. If the disk is still full after all this, the file manager's own disk-usage view (or ncdu /) will point straight at whatever's left. The golden rule from our essential commands guide still applies: read the path twice before you delete, and never rm -rf something you don't understand.