← Disk & Filesystem
Linux · Disk & Filesystem

How to find what is using disk space in a directory in Linux

Find which directories and files are consuming space with du, including a sorted top-N of the biggest subdirectories.


Find what is filling a directory. du sums the space under each path; sort it to see the biggest offenders.

# Total size of a directory
du -sh /var

# Immediate subdirectories, smallest to biggest
du -h --max-depth=1 /var | sort -h

# Top 10 biggest subdirectories
du -h --max-depth=1 /var 2>/dev/null | sort -rh | head -n 10

# Biggest items including files
du -ah /var 2>/dev/null | sort -rh | head -n 20
LinuxduDisk Space