How to Quickly Identify Disk Space Hogs on Linux Servers
Learn step-by-step methods to locate large directories and files consuming disk space on Linux servers, using commands like df, du, find, and lsof, plus tips for handling deleted files and adjusting reserved space with tune2fs to reclaim lost storage.
During server operations we often receive disk‑space alerts. Running df -Hl shows the current usage, but we need to pinpoint the directories or files that fill the disk.
One simple way is to list the size of each top‑level directory with du -hs and then drill down.
More efficient search with depth limits
Use du -d 2 or du --max-depth=2, pipe the output to grep for entries measured in G or T, and sort descending.
du -h -d 2 | grep [GT] | sort -nr
du -h --max-depth=2 | grep [GT] | sort -nrAlternatively, find can locate large files directly.
find / -type f -size +1G -exec du -h {} \; findis generally faster and more flexible than du.
These techniques quickly reveal the biggest space consumers.
Why du and df totals may differ
Sometimes the sum of sizes reported by du is far less than the usage shown by df. This often means space is held by deleted files that are still open.
Use lsof +L1 to list such files.
lsof +L1In the example a ~28 GB log file had been deleted but its space was not released; restarting the Tomcat service freed it.
Reserved space for the root user
Linux reserves about 5 % of the filesystem for the root user, which can make Used + Avail appear smaller than Size. The reservation can be changed with tune2fs.
tune2fs -m 1 /dev/vda1After reducing the reserved percentage, the previously “missing” space becomes available.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
