Operations 4 min read

How to Quickly Identify Disk Space Hogs on Linux Servers

When a Linux server raises a disk‑space alarm, this guide shows step‑by‑step how to locate the offending directories or files using df, du, find, lsof and tune2fs, and explains why reported usage may differ from summed directory sizes.

Liangxu Linux
Liangxu Linux
Liangxu Linux
How to Quickly Identify Disk Space Hogs on Linux Servers

During routine server operations you may receive a disk‑space warning. First, verify the reported usage with df -Hl and compare it to the alert.

Finding Large Directories with du

A simple method is to run du -hs * in the root directory to list each subdirectory’s size, then drill down recursively.

For a more efficient search, limit the depth and filter the results:

du -h -d 2 | grep [GT] | sort -nr
# or
du -h --max-depth=2 | grep [GT] | sort -nr

This lists directories whose sizes are expressed in gigabytes (G) or terabytes (T) and sorts them descending.

Using find for Large Files

The find command can locate large files quickly: find / -type f -size +1G -exec du -h {} \; Compared to du, find is often faster and more flexible.

Detecting Deleted Files Still Holding Space

If the summed sizes from du are far less than the total used space shown by df, deleted files may still be open. Use lsof +L1 to list such files: lsof +L1 The output may reveal large log files (e.g., a 28 GB file) that were deleted but not released. Restarting the associated service (e.g., Tomcat) frees the space.

Understanding Reserved Space

Linux filesystems reserve a percentage (default 5%) of disk space for the root user, which can cause the Used + Avail values to be less than Size. Adjust the reservation with tune2fs: tune2fs -m 1 /dev/vda1 Reducing the reserved percentage from 5% to 1% releases the hidden space, as shown by the before‑and‑after comparison.

By following these commands, you can efficiently pinpoint the root cause of disk‑space exhaustion and resolve it.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Operationsfindlsofdu
Liangxu Linux
Written by

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.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.