LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-30-2009, 05:17 AM   #1
laki47
Member
 
Registered: Feb 2009
Posts: 33

Rep: Reputation: 15
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!
 
Old 04-30-2009, 05:31 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
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.
 
Old 04-30-2009, 05:50 AM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian + kde 4 / 5
Posts: 6,834

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
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
 
Old 04-30-2009, 06:07 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
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!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ Output question vibrokatana Programming 9 10-15-2007 06:27 PM
sed coomand ancys Programming 4 08-03-2006 11:27 AM
Question about output for php Hockeyfan Programming 1 03-14-2006 10:30 AM
iwconfig output question scowles Linux - Wireless Networking 2 12-03-2004 06:11 PM
C Output Question drigz Programming 13 09-10-2004 08:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration