LinuxQuestions.org
Help answer threads with 0 replies.
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 06-24-2013, 09:27 PM   #1
gacanepa
Member
 
Registered: May 2012
Location: San Luis, Argentina
Distribution: Debian
Posts: 203

Rep: Reputation: 26
Output of ls -lh (size of directories)


Dumb question, I know: why is the size of a directory always 4.0K? (I mean the output of ls -lh) - independently of its contents (in this example, the actual size of the contents of the Thunderbird directory is around 5 GB). On the other hand, for a regular file it displays its actual size.
Code:
-rwx--x--x  1 gacanepa gacanepa 1.6K Apr 11 20:04 deborphan.py
drwxr-xr-x  2 gacanepa gacanepa 4.0K Apr  2 17:28 Templates
drwxr-xr-x 17 gacanepa gacanepa 4.0K Apr  5 21:12 Thunderbird
drwxr-xr-x  2 gacanepa gacanepa 4.0K Apr  2 17:28 Videos
Thanks in advance!
 
Old 06-24-2013, 09:36 PM   #2
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
because ls does not dive into subdirectories. for that you need tree, or use du -sch to calculate properly the total size of files in a directory tree.
 
1 members found this post helpful.
Old 06-24-2013, 09:43 PM   #3
gacanepa
Member
 
Registered: May 2012
Location: San Luis, Argentina
Distribution: Debian
Posts: 203

Original Poster
Rep: Reputation: 26
Quote:
Originally Posted by lleb View Post
because ls does not dive into subdirectories. for that you need tree, or use du -sch to calculate properly the total size of files in a directory tree.
Thanks a lot! I marked your answer as helpful.
 
Old 06-24-2013, 09:59 PM   #4
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
hope it helped.

here is an example:

Code:
[ray@centos /]$ ls -lh /tmp/
total 68K
drwx------. 2 ray  ray  4.0K Jun 24 17:47 ssh-QMowdf3405
-rw-------. 1 root root  61K Jun 17 20:28 yum_save_tx-2013-06-17-20-28Ol8WnH.yumtx
[ray@centos /]$ du -sch /tmp/
76K	/tmp/
76K	total
hope that helps.
 
1 members found this post helpful.
Old 06-25-2013, 12:20 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
Actually, its also because the default FS block size these days is 4k
Code:
tune2fs -l /dev/sdb2|grep 'Block size'
Block size:               4096
 
1 members found this post helpful.
  


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
Sort Directories by size richinsc Linux - General 8 03-11-2010 04:39 PM
Good Memory Size and Moemory Size in lsconf output Jaimine AIX 3 05-18-2009 02:07 PM
View directories size rickylim Linux - General 3 07-19-2006 12:24 AM
directories size is always 4K Milosevic Linux - Newbie 7 12-10-2005 06:59 PM
hd partition size/directories ziggie216 Linux - General 3 11-10-2005 12:58 PM


All times are GMT -5. The time now is 06:48 PM.

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