What it does
du (disk usage) adds up the space that files use, folder by folder. Where df tells you that a file system is full, du tells you which folder fills it.
By default it shows every sub-folder. Usually you want -s (one total per argument), -h (readable sizes) and --max-depth=1 (one level).
How to write it
du [OPTION]... [FILE]...Options 27
Most used
Nothing matches this filter.
Examples 12
$ run as a normal user# run as root (or with sudo)
1Size of one folder
du -sh /var/log 2.1G /var/logOne line, readable size.
2Which sub-folder is big?
du -h --max-depth=1 /var | sort -hSorted, the biggest at the bottom. Then go one level deeper.
3The 10 biggest folders on the root file system
-xstays on/and does not count other mounts.4Sizes of all home folders
du -sh /home/*Who uses the most space?
5Show files too, bigger than 100 MiB
Lists big files and folders.
find -size +100Mis another way.6Leave out some files
du -sh --exclude='*.iso' ~/DownloadsSize without the ISO images.
7Count files instead of size
Finds folders with millions of small files (when df -i is at 100%).
8Grand total of several folders
du -shc /var/log /var/cache /tmpThe last line is the total.
9Real size vs. apparent size of a VM disk
du -h vm.qcow2; du -h --apparent-size vm.qcow2A sparse file can look big but use little space.
10Show when folders changed
du -h --time -d 1 /srv/backupsFind backup folders that stopped growing.
11Only show folders above 1 GiB
du -h -t 1G -d 2 /var/libHides all the small stuff.
12Check container storage
du -sh /var/lib/containers/storageContainer images often fill /var.
podman system prunecleans unused images.
Nothing matches this filter.
Watch out
- du counts only files it can read. Run it as root for system folders.
dudoes not see deleted files that are still open;dfdoes. That explains differences.- On big trees du can take time and a lot of disk reads.
Tips to remember
du -sh *= sizes here.du -h -d1 | sort -h= biggest last.