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