51

du and df do rather similar things, and so I always find myself typing the wrong one.

I think if I knew what "du" and "df" stands for it might make it easier to remember which to use.

What is a way to differentiate between these two so I can remember which does which action?

Cory Klein
  • 18,911

2 Answers2

76

du == Disk Usage. It walks through directory tree and counts the sum size of all files therein. It may not output exact information due to the possibility of unreadable files, hardlinks in directory tree, etc. It will show information about the specific directory requested. Think, "How much disk space is being used by these files?"

df == Disk Free. Looks at disk used blocks directly in filesystem metadata. Because of this it returns much faster that du but can only show info about the entire disk/partition. Think, "How much free disk space do I have?"

jw013
  • 51,212
rush
  • 27,403
  • 2
    Actually I would argue that du stands for "Directory Usage" (but yes, it is debatable :-P ) – phemmer Jun 28 '12 at 22:27
  • 7
    By the way even in the man page is written du - display disk usage statistics. – rush Jun 29 '12 at 12:55
  • But is shows directory usage. Disk usage is what df does. So perhaps the man-page is the source of confusion here... – Nils Jun 29 '12 at 19:23
  • 7
    I was going to say that! +1 for beating me to it. I think "disk usage" is more appropriate than "directory usage" if you think of it as "disk usage for the files named as arguments." You can feed du(1) a long list of files, and it won't show any directory stats at all. – Jan Steinman Jul 04 '12 at 17:50
  • To me, "disk usage" could be interpreted as "disk usage for all my files", but "disk free" is certainly explicit. – Sparhawk Feb 03 '16 at 01:56
-4

du is used more than df in day to day project as it shows the disk usage as per directory level.

df is disk free space and shows at file system level. Another command is dfspace which would also be used.

Kevdog777
  • 3,224
abc
  • 1
  • 1
    What's dfspace? How would I install it? It's not in the Debian repositories and I've never heard of it. – terdon Apr 09 '15 at 10:14