Why du and df show different results?

Why du and df show different results?

du is used to estimate file space usage—space used under a particular directory or files on a file system. So after deleting the file, the results of df and du are different until the disk space is released.

What is du output?

Use this command to estimate how much disk space each specified file or subdirectory uses. Output will summarize each “ ” variable entry as disk usage in bytes. …

What is the purpose of the du command?

Summarize disk space used for each FILE and/or directory. Disk space is printed in units of 1024 bytes
du/Function

Is du in bits or bytes?

If you do not specify any pathname, du assumes the current directory. Files with multiple links are only counted once. du measures file space in 512-byte units. The attempt is made to report actual file space used, if possible.

What’s the difference between DF-H and du?

While du shows that the /opt’s size is only 1.1.G, df -h showing its 16G space is 100% utilized. Any idea what is going on here? :O

Do you need to test the return status of sha1sum?

So, if you are comparing two directories from the different file system (e.g. Ext3 vs. APFS), you need to sort first before the final sha1sum. (added by Xianjun Dong) The short answer: don’t test the file size, test the return status of the command.

Why do I run du without apparent size?

When you run du without the –apparent-size you’re getting the size based on the amount of disk’s block space used, not the actual space consumed by the file (s). using a checksum instead? This is likely a better option if you’re concerned about comparing 2 trees of files.

Is there a way to check if a copy succeeded?

The return status the only a reliable indication of whether the copy succeeded (short of comparing the two files byte by byte, directly of indirectly — which is redundant if the copy succeeded). Checking the file size is not a very useful way of checking whether a copy succeeded.