Ever seen the dreaded "Disk Full" error on your Linux server? Whether you're managing a production box or your personal homelab, running out of space on the root partition is a headache.
In this guide, we'll go beyond the basics. You'll learn how to quickly check your disk status, pinpoint exactly which folders are eating your storage, and find the massive files hiding in your system.
1. Check Overall Disk Usage (The High-Level View)
The first step is always checking the overall status. Use df (disk free).
df -h
-
-hflag: Makes it "human-readable" (GB/MB instead of blocks). -
Focus on: The
Use%andMounted oncolumns. If/is at 95%+, it's time to act.
2. Spot the Heavy Folders with du
Now that you know a disk is full, you need to find out where. du (disk usage) is your best friend here.
Summarize the current directory:
du -sh .
List and sort all folders in the current directory by size:
du -sh * | sort -h
3. Pro Tip: Root Partition Breakdown (/)
When the root folder is full, you need to see which system directory is to blame. Run this to see a one-level breakdown of the root:
sudo du -xh --max-depth=1 / 2>/dev/null | sort -hr
-
-x: Stays on one file system (prevents digging into mounted drives/network shares). -
--max-depth=1: Keeps the output clean and manageable.
4. Hunting for Massive Files
Sometimes it's not a folder, but one or two giant log files or ISOs.
Find the Top 20 largest files on your entire system:
sudo find / -type f -printf "%s %p\n" | sort -rn | head -n 20 | awk '{print $1/1024/1024 "MB", $2}'
Find files larger than 100MB specifically:
sudo find / -type f -size +100M -exec ls -lh {} +
5. The "Modern" UI Way: ncdu
If you prefer a visual, interactive interface in your terminal, ncdu is a game-changer. It provides a UI to browse your filesystem and delete files directly.
Install it:
sudo apt install ncdu # Debian/Ubuntu
sudo dnf install ncdu # RHEL/CentOS
Run it:
ncdu /
Summary Checklist
-
df -h: "How much space do I have left?" -
du -sh * | sort -h: "Which folder is the biggest?" -
find / -size +100M: "Where are the massive files hiding?" -
ncdu: "Let me browse and clean up visually."
Whatβs your favorite command for cleaning up Linux? Let me know in the comments! π
If you found this helpful, follow me for more Linux tips and digital familiar insights!
Top comments (0)