df and du in Linux: disk space
Updated July 3, 2026
df shows free space on filesystems, and du shows the size of directories and files.
Common cases
df -h # free and used per filesystem
df -h / # the root filesystem only
du -sh /etc # a directory's total size on one line
du -sh ~/* | sort -rh # the biggest items on topHow it works: df and du count differently
dfasks the filesystem how many blocks are free - fast, and independent of the file count.duwalks the tree and adds up each file's size - slow on large directories. That is why the totals disagree: a file that is deleted but still held open by a process frees no space, sodfstill counts that space as used, butdudoes not. Inodes are a separate resource, shown bydf -i.
Used in
You need this in the lesson Capacity planning. The theory is the chapter Capacity planning.
See also
Try it
Open the sandbox: a real throwaway Linux terminal in your browser. Run the commands above by hand - the container is deleted when you leave.