How to Quickly Identify Disk Space Hogs on Linux Servers
Learn step-by-step Linux techniques—including df, du, find, and lsof commands—to pinpoint large directories or files, filter results, handle hidden space consumption, and adjust reserved filesystem space, ensuring you can efficiently resolve unexpected disk usage issues on your servers.
During server operations you may receive disk‑space alerts. Use df -Hl to view the current usage.
How to locate large directories or files
A simple way is to run du -hs in the root directory and then drill down into the reported directories.
A more efficient method adds the -d or --max-depth option to limit depth, piping the output through grep to filter and sort the results, which quickly reveals directories measured in G or T.
You can also use find to search for big files, for example: find / -type f -size +1G -exec du -h {} \; In terms of speed, find is generally faster and more flexible than du.
Dealing with hidden space consumption
Sometimes the sum of sizes reported by du is far less than the usage shown by df. This often means deleted files are still holding space.
Use lsof +L1 to list open files that have been deleted. An example output may show a ~28 GB log file that is deleted but still occupies space. lsof +L1 Restarting the affected application (e.g., Tomcat) releases the space.
Why used space may appear larger than expected
Linux reserves a percentage of disk space (default 5 %) for the root user as a safety buffer, which can make Used + Avail < Size.
You can adjust this reserved space 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.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
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.
