Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
39
rated 0 times [  39] [ 0]  / answers: 1 / hits: 49152  / 2 Years ago, mon, october 17, 2022, 8:57:10

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:-



$ ls -lh
total 2.0M
drwxr-xr-x 4 ankit ankit 4.0K Sep 11 07:28 Desktop

$ ls -lrh Desktop/
-rw-rw-r-- 1 ankit ankit 9.1M Aug 4 11:15 sophosthreatsaurusaz.pdf
-rw------- 1 ankit ankit 107K Dec 27 2010 KP 3 0.pdf
drwxrwsr-x 9 ankit ankit 4.0K Sep 10 19:26 eclipse


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



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


More From » filesystem

 Answers
0

  • 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.


[#35607] Tuesday, October 18, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
splenueak

Total Points: 448
Total Questions: 118
Total Answers: 110

Location: Vanuatu
Member since Mon, Oct 3, 2022
2 Years ago
;