Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 04-24-2008, 08:19 AM   #1
Registered: Oct 2005
Distribution: Ubuntu 9.04
Posts: 124
Blog Entries: 2

Rep: Reputation: 15
help with ls -lh -lhd

hi everyone..i have this terminal window

cumhur@pvs-a:~$ cd testarchiv/
cumhur@pvs-a:~/testarchiv$ ls -lh
total 260K
-rw-r--r-- 1 cumhur cc08 256K 2008-04-24 13:22 zufallsdatei
cumhur@pvs-a:~/testarchiv$ cd ..
cumhur@pvs-a:~$ ls -lhd testarchiv/
drwxr-xr-x 2 cumhur cc08 4,0K 2008-04-24 13:22 testarchiv/
the directory has only a file which is 256K..why does it appear like 4.0K after ls -ldh ?
Old 04-24-2008, 08:43 AM   #2
Senior Member
Registered: Oct 2006
Distribution: Slackware 12 Kernel 2.6.24 - probably upgraded by now
Posts: 1,054

Rep: Reputation: 46
ls -d shows only directory entries which are always just 4K
Old 04-24-2008, 08:47 AM   #3
Registered: Oct 2005
Distribution: Ubuntu 9.04
Posts: 124
Blog Entries: 2

Original Poster
Rep: Reputation: 15
thanks a lot..
Old 04-24-2008, 08:51 AM   #4
Senior Member
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
My explanation may not be 100% on track with my thinking, so somebody please correct me if need be, but here goes:

The -d option for ls only lists the "directory entries instead of the contents"; which makes me think that it will only list the directories within the current working directory and not the files within. (I don't have access to a Linux box right now, so I can't test this theory out.)

The reason the size of the directory is only 4.0K is a nice reminder that you're using a UNIX-oriented system: everything is a file. Directories are just pointers to table entries, and what you're getting is the size of the file that is required to direct the computer to the appropriate "inode" table. Once formatted, a hard drive is nothing more than a giant inode table which says, "This file exists here, this directory refers to the container for these files...", etc.


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
What happened to SparceMatrix Linux - Hardware 0 02-01-2003 04:55 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:52 PM.

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