Checking File Size with du and Disk Usage with df on Linux

Tech Sharing 2017-12-19
Checking File Size with du and Disk Usage with df on Linux

A du and df quick reference: du for directory/file usage, df for disk usage, with options like -h, -a, -s and --max-depth.

du command

Common options: -h human-readable units; -a show directories and their files; -s show only the directory total, not subdirectories/files.

du -h                          show all dirs under the current dir (incl. subdirs)
du -a -h                       show all dirs and files (incl. subdirs)
du -a -h --max-depth=1         list one level under the current dir
du -s -h                       total size of the current dir

df command

df -h    output in human-readable format (e.g. 1K, 1M, 1G)

Options: -a all filesystems; -h human-readable; -H like -h but 1K=1000; -i show inode info; -k 1024-byte blocks; -l local filesystems only; -m 1048576-byte blocks; --no-sync skip sync; -P POSIX output; --sync run sync before reading; -T show filesystem type.