How to Quickly Identify Disk Space Hogs on Linux Servers
This guide explains how to diagnose unexpected disk usage on Linux by using df, du, find, and lsof commands, demonstrates efficient ways to locate large directories or deleted files, and shows how to adjust reserved space with tune2fs to reclaim lost storage.
During server operations, disk space alerts are common; you can start by checking usage with df -Hl.
The goal is to pinpoint the directories or files that consume the most space.
Method 1 – Simple du scan : Run du -hs in the root directory to list each top‑level directory’s size, then repeat the command in the larger directories to drill down.
Method 2 – Depth‑limited du with filtering : Use du’s depth options together with grep to show only entries measured in gigabytes or terabytes and sort them.
du -h -d 2 | grep [GT] | sort -nr
du -h --max-depth=2 | grep [GT] | sort -nrThis quickly surfaces the biggest consumers.
Method 3 – Using find : The find command can locate large files more efficiently.
find / -type f -size +1G -exec du -h {} \; findis generally faster and more flexible than du for this purpose.
Sometimes the total size reported by du does not match df because deleted files are still held open by processes. List such files with: lsof +L1 In the example, a ~28 GB log file had been deleted but its space was not released; restarting the Tomcat service freed the space.
Another common discrepancy is that df shows used + available less than the total size. Linux filesystems reserve a percentage (default 5 %) of space for the root user to ensure critical services can continue when the disk is full.
You can modify this reservation with tune2fs: tune2fs -m 1 /dev/vda1 After 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.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
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.
