[Linux] Command to Check Directories with High Disk Usage

Tadashi Shigeoka ·  Tue, November 12, 2019

I’ll introduce a Linux command to display directories sorted by highest disk consumption.

Linux

Background: Responding to Disk Full Warning

I received a disk full warning, so I looked up Linux commands to identify directories consuming large amounts of disk space.

/dev/nvme0n1p1 at 85% Use% causing disk full warning

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        3.9G   56K  3.9G   1% /dev
tmpfs           3.9G     0  3.9G   0% /dev/shm
/dev/nvme0n1p1   20G   17G  3.2G  85% /

Checking Directories with High Disk Usage on Linux

Top 3 Directories with Highest Disk Usage

du -S / | sort -rn | head -3

Practical Example: Display Top 3 Disk Usage Across Entire Linux Server

sudo su -
cd /

du -S / | sort -rn | head -3
836172  /u/apps/example.com/shared/uploads
542596  /u/apps/example.com/shared/cached-copy/.git/objects/pack
263120  /home/ec2-user/.fonts/NotoSansCJKsc

That’s all from the Gemba.

Reference Information