du will only count each file once if it is linked to multiple times. If you run
du -L bar it will count the file because it only reaches it once. However, if you run
du -L * it will only count it the first time it sees it. For example:
$ du -L foo bar
$ du -L bar foo
Notice that swapping the order of the arguments changes which folder gets reported as 16K.
You can force
du to count the file twice by passing the
Symbolic links are a special kind of file, and an extra step is needed to follow the link.
du will not follow symbolic links unless the
-L option is enabled.
A hard link on the other hand, is basically one file existing in two (or more) folders.
du presumably tracks which files it has seen by inode number to avoid counting these twice.
-l disables this behaviour.
So, with just
-L, it will follow the symbolic link, but if the target file has an inode number it has already seen it will not be re-counted. With just
-l it will count duplicate hard links, but will not follow symbolic links.
If you use
-L together, it will both follow the symbolic links, and also allow counting the target file(s) more than once.