A disk that keeps filling up is one of the most common problems on a Linux server. When a service dies or a write fails, the first thing I check is whether the disk is full. Here is the stack I reach for every time: df -h to see overall usage, du -sh to find the heavy directories, and ncdu when I need an interactive view to drill down fast.
ncdu GitHub: dev.yorhel.nl/ncdu
Source: blog.zulfahmy.net
df -h: see disk usage at a glance
df reports filesystem usage. The -h flag prints sizes in a human readable format. This is my first move because it tells me instantly which filesystem is full and how much is left.
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 492G 482G 1.2G 99% /
tmpfs 3.9G 0 3.9G 0% /dev/shmThe Use% column is the tell. When that number sits in the 90s, the disk is nearly full and I move on to finding what is eating it.
du -sh: find the heavy directories
du sums up the disk used by files. Combined with -sh it prints a single total per directory, which is perfect for spotting the culprit. I run it against the mount point shown by df.
du -sh /* 2>/dev/null
4.0K /bin
4.0K /boot
380G /var
1.2G /opt
Redirecting stderr with 2>/dev/null keeps the output clean when I hit directories I cannot read. Once a big one shows up, I drill into it the same way.
du -sh /var/* 2>/dev/null | sort -rh | head -10
350G /var/log
120G /var/lib
sort -rh sorts human readable sizes with the biggest first, so the top offenders jump out immediately.
ncdu: interactive disk usage explorer
When du still leaves me guessing, I switch to ncdu. It scans the filesystem and shows a browsable, interactive list sorted by size. Install it first, then point it at a directory.
sudo apt install ncdu # Debian/Ubuntu
sudo dnf install ncdu # Fedora/RHELRun it on a specific mount point. The -x flag keeps it inside one filesystem, so it skips other mounts and virtual filesystems. That makes the scan faster and the numbers accurate for the disk I actually care about.
ncdu -x /
ncdu 1.18 ~ Use the arrow keys to navigate, press ? for help
--- / -----------------------------------------------------------------------
37.2 GiB [##### ] /var
8.1 GiB [## ] /usr
4.3 GiB [# ] /opt
Arrow keys move through the list, Enter dives into a directory, d deletes an entry, and q quits. It is the fastest way to chase a full disk down to a single oversized file.
That is my whole storage troubleshooting loop: df -h to confirm the full disk, du -sh to narrow it down to a directory, and ncdu to drill into the exact files. I keep it simple because when a disk is full, the quickest fix usually beats the clever one.