SkillByAIOpen interactive version →

Lesson 30 / 31

Disk Usage

Find where disk space goes with df for filesystems and du for directories sorted by size.

df — filesystem space

df -h shows free/used space per mounted filesystem, in human-readable units.

df -h

Output:

Filesystem  Size  Used Avail Use% Mounted on
/dev/sda1    50G   32G   16G  67% /

du — directory size

du -sh dir shows a directory's total size; sort the biggest offenders with du -sh * | sort -h.

du -sh /var/log
du -sh * | sort -h

Output:

128M    /var/log