1

I'm using Ubuntu 14.04 and I made an empty directory on /tmp with the mkdir command:

cd /tmp
mkdir foo

and then I checked it's size using ls:

ls -ldh foo

and the result shows that the size of the directory is 4KB, although it has nothing inside!

then I created an empty file with touch:

touch empty

and then I checked its size:

ls -l empty

the result shows that the empty file is of 0B, which differs from the empty directory.

I've read about some Q&A's saying that the 4KB is the metadata of the directory. But if it is the metadata, what kind of information is stored inside and why it is so huge, and why an empty file don't have such kind of metadata? If it is not the metadata, what does the 4KB mean?

Roy
  • 129
  • A point that doesn't seem to have been made elsewhere — not even in the question of which this is a duplicate — is that there is no such thing as an empty directory; every directory (except in pathological cases) contains at least the entries "." and "..".  Then the rest of the answer lies in the facts that 4096 bytes is the default allocation unit (block) for ext2/ext3/ext4 filesystems, and that the system always allocates full blocks for directories. – G-Man Says 'Reinstate Monica' Jun 03 '15 at 09:52

1 Answers1

0

As mentioned in the question: What does size of a directory mean in output of 'ls -l' command? The metadata of the folder is always stored in blocks, so it allocates 4kb even if there is not much data that needs to be stored.

-Duplicate Question.