How to remember the difference between du and df?

63,539

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?"

Share:
63,539

Related videos on Youtube

Cory Klein
Author by

Cory Klein

Updated on September 18, 2022

Comments

  • Cory Klein
    Cory Klein over 1 year

    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
      Cory Klein almost 12 years
      Hah, Unix & Linux's tag autofill has already partially answered my question! Way to go! (I had tagged the question du, and after submission it autofilled it to disk-usage)
    • Tim
      Tim almost 12 years
      Nice, stackexchange win!
    • Kedar Vaidya
      Kedar Vaidya almost 12 years
      For what it's worth, df looks at the file system, so I always mapped df with f with that
  • phemmer
    phemmer almost 12 years
    Actually I would argue that du stands for "Directory Usage" (but yes, it is debatable :-P )
  • rush
    rush almost 12 years
    By the way even in the man page is written du - display disk usage statistics.
  • Nils
    Nils almost 12 years
    But is shows directory usage. Disk usage is what df does. So perhaps the man-page is the source of confusion here...
  • Jan Steinman
    Jan Steinman almost 12 years
    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.
  • terdon
    terdon about 9 years
    What's dfspace? How would I install it? It's not in the Debian repositories and I've never heard of it.
  • Sparhawk
    Sparhawk over 8 years
    To me, "disk usage" could be interpreted as "disk usage for all my files", but "disk free" is certainly explicit.