How to remember the difference between du and df?
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?"
Related videos on Youtube
Cory Klein
Updated on September 18, 2022Comments
-
Cory Klein over 1 year
du
anddf
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 almost 12 yearsHah, 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 todisk-usage
) -
Tim almost 12 yearsNice, stackexchange win!
-
Kedar Vaidya almost 12 yearsFor what it's worth, df looks at the file system, so I always mapped df with f with that
-
-
phemmer almost 12 yearsActually I would argue that
du
stands for "Directory Usage" (but yes, it is debatable :-P ) -
rush almost 12 yearsBy the way even in the man page is written
du - display disk usage statistics
. -
Nils almost 12 yearsBut is shows directory usage. Disk usage is what
df
does. So perhaps the man-page is the source of confusion here... -
Jan Steinman almost 12 yearsI 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 about 9 yearsWhat's
dfspace
? How would I install it? It's not in the Debian repositories and I've never heard of it. -
Sparhawk over 8 yearsTo me, "disk usage" could be interpreted as "disk usage for all my files", but "disk free" is certainly explicit.