Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

As the subject says; I want to know why is every directory having a size equals to 4K even if they contain files with sizes greater than 4K.

Please have a look at the following:-

a)

size of the Desktop Directory under my ~ folder

b)

files in the desktop directory

PS: I am aware of 'du -sh' command line utility.


edit: I am assuming directory as a container for files.

share|improve this question
It is the meta-data of the directory – Tachyons Sep 12 '12 at 6:01

2 Answers

up vote 3 down vote accepted
  • Without getting too technical, think of a directory entry as simply a "link" to a list of the files the directory "contains."
  • Then, as with everything, ls shows you the size of that link, not the total space occupied by the contents of the directory.
  • The minimum size a file or directory entry/link must occupy is one block, which is usually 4096 bytes/4K on most ext3/4 filesystems.
share|improve this answer

If a file contains any data at all (even a single byte), it will occupy one block on the disk (which is typically 4k these days). One block cannot be shared between files. This means that the space of that whole block will not be available for other files, so it is considered "used".

Source

share|improve this answer
1  
You should use block-quote when using direct quote from other source, because this can confuse users – Anwar Sep 12 '12 at 3:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.