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
More on Storage & Memory
How do you list disks, partitions and filesystems?IntermediateMBR vs GPT partition tables?IntermediateWalk through adding a new disk and mounting it permanently.IntermediateExplain the six fields of an /etc/fstab line.IntermediateWhy use UUIDs and `nofail` in fstab?IntermediateWhat does a bad fstab entry do, and how do you recover?Advanced