Interview Prep/Linux/Storage & Memory

What is the difference between df and du?

BeginnerConceptStorage & Memory
Answer

df asks the filesystem how many blocks are allocated in total (superblock stats). du walks directories and adds up the files it can see. They disagree when files are deleted but still open, when files are hidden under a mount point, or because of reserved blocks and metadata.

df -h /var
sudo du -xh --max-depth=1 /var | sort -h
All Linux questions Roadmap: Linux

More on Storage & Memory