Operations 4 min read

How to Quickly Identify Disk Space Hogs on Linux Servers

This guide shows step‑by‑step Linux commands—df, du, find, lsof, and tune2fs—to pinpoint large directories, uncover hidden space used by deleted files, and adjust reserved root space, helping you resolve mysterious disk‑space alerts efficiently.

Efficient Ops
Efficient Ops
Efficient Ops
How to Quickly Identify Disk Space Hogs on Linux Servers

How to Find Large Directories or Files

When a server triggers a disk‑space alarm, start by checking the filesystem with

df -Hl

to confirm the reported usage.

To locate the offending directories, a straightforward approach is to run

du -hs

in the root directory and then repeat the command in sub‑directories.

A more efficient method uses

du

with the

-d

or

--max-depth

option together with

grep

to filter and sort results, allowing you to quickly spot directories that occupy gigabytes or terabytes.

Alternatively, the

find

command can directly search for large files, e.g.:

<code>find / -type f -size +1G -exec du -h {} \;</code>

In practice,

find

is often faster and more flexible than

du

.

Sometimes the sum of sizes reported by

du

does not match

df

because deleted files are still held open. Use

lsof +L1

to list such files; restarting the related service (e.g., Tomcat) releases the space.

<code>lsof +L1</code>

Linux also reserves a percentage of disk space for the root user (default 5%). This reservation can be changed with

tune2fs -m 1 /dev/vda1

, which reduces the reserved space to 1% and frees up the previously hidden capacity.

<code>tune2fs -m 1 /dev/vda1</code>
Linuxdisk usagefindlsofdudfServer Operationstune2fs
Efficient Ops
Written by

Efficient Ops

This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.

0 followers
Reader feedback

How this landed with the community

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