Frequently Asked Question

What is the difference between du and df?

df ("disk free") asks each mounted filesystem how much space it has, by reading filesystem metadata directly. It is fast and gives a top-down view: total size, used, available, and percentage for every mount point. df -h adds human-readable units and df -i shows inode usage instead of bytes. It is the right tool when you want to know whether a filesystem is filling up.

du ("disk usage") walks a directory tree and adds up the size of every file it finds. It is slower because it has to stat everything, but it tells you where the space has gone: du -sh /var/* lists each subdirectory of /var with a single total. The two numbers will not always agree, du does not see space held by deleted-but-open files, and filesystem overheads like inode tables and journals are invisible to du but accounted for by df. A pleasant interactive cousin, ncdu, is worth installing for hunting down what is eating your disk.

Video

Further reading and video