LinuxQuestions.org
Visit Jeremy's Blog.
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, 08:27 PM   #1
gacanepa
Member
 
Registered: May 2012
Location: San Luis, Argentina
Distribution: Debian
Posts: 205

Rep: Reputation: 27
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, 08:36 PM   #2
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
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, 08:43 PM   #3
gacanepa
Member
 
Registered: May 2012
Location: San Luis, Argentina
Distribution: Debian
Posts: 205

Original Poster
Rep: Reputation: 27
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, 08:59 PM   #4
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
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-24-2013, 11:20 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,348

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
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 03:39 PM
Good Memory Size and Moemory Size in lsconf output Jaimine AIX 3 05-18-2009 01:07 PM
View directories size rickylim Linux - General 3 07-18-2006 11:24 PM
directories size is always 4K Milosevic Linux - Newbie 7 12-10-2005 05:59 PM
hd partition size/directories ziggie216 Linux - General 3 11-10-2005 11:58 AM

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

All times are GMT -5. The time now is 06:26 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
Open Source Consulting | Domain Registration