LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   ls -l coomand output - question (https://www.linuxquestions.org/questions/linux-newbie-8/ls-l-coomand-output-question-722655/)

laki47 04-30-2009 04:17 AM

ls -l coomand output - question
 
Hello!

Can you explain me please column 5 (1024)

drwxr-sr-x 2 root root 1024 Apr 30 11:05 test
-rw-r--r-- 1 root root 100697 Feb 03 13:55 test.log

Why the directory "size" is always 512 or 1024 or 2048?

What does it mean?

Thank you!

acid_kewpie 04-30-2009 04:31 AM

it's the size of an inode on the filesystem the directory exists. A directory still needs to exist on the drive in some form, and entry on the filesystem - files, links, directories etc. use up at least one inode to exist. That's my understanding and i think i do recall seeing different "sizes" of directory within the same filesystem, which I'm not too sure of the reasons for.

David the H. 04-30-2009 04:50 AM

Hmm. My listing doesn't show regular block sizes. I get much more precise numbers.
Here's a selection from my home directory:

Code:

drwxrwx---  2 david david    520 2009-02-06 20:24 Desktop
drwxrwx--- 11 david david  1624 2009-04-13 21:54 documents
drwxrwx--- 12 david david    408 2007-05-05 10:53 programs
drwxrwx--- 12 david david    784 2009-04-27 22:05 temp
drwxrwx---  2 david david    352 2009-04-27 22:05 test


druuna 04-30-2009 05:07 AM

Hi,

The size of a directory starts as the blocksize, on modern systems with larger disk this will, most often, be 2048/4096. This directory file contains all info about itself and all the files/dirs inside it. So far I'm just repeating acid_kewpie......

The size of this directory file can grow over time (lots of files/dirs added inside that dir). The funny part is that this info is not released/removed after you delete a file/dir in that dir!

Here's a real life example. My /data/Pan/Pictures directory, used to place files before I sort them out and move/delete them. There can be hundreds of files or none at all (which is true for this example):
Code:

$ ls -ld Pictures*
drwx------ 2 druuna internet 266240 Apr 30 11:51 Pictures

$ ls -l Pictures
total 0

$ mkdir Pictures2
$ ls -ld Pictures*
drwx------ 2 druuna internet 266240 Apr 30 11:51 Pictures
drwxr-x--- 2 druuna internet  4096 Apr 30 11:54 Pictures2

$ rm -rf Pictures

$ mkdir Pictures

$ ls -ld Pictures*
drwxr-x--- 2 druuna internet 4096 Apr 30 11:54 Pictures
drwxr-x--- 2 druuna internet 4096 Apr 30 11:54 Pictures2

$ ls -la Pictures*
Pictures:
total 20
drwxr-x--- 2 druuna internet  4096 Apr 30 11:54 .
drwx------ 8 druuna internet 16384 Apr 30 11:54 ..

Pictures2:
total 20
drwxr-x--- 2 druuna internet  4096 Apr 30 11:54 .
drwx------ 8 druuna internet 16384 Apr 30 11:54 ..

As you probably noticed the 'directory' had a size of 266240, even though it was empty. After deleting and re-creating the directory, the default size is back again.

I don't know why it is implemented this way, there must be a reason for not removing the information form the directoryfile. Maybe this is done to be able to restore deleted files, but that is just a guess!


All times are GMT -5. The time now is 07:44 AM.