LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   help with ls -lh -lhd (https://www.linuxquestions.org/questions/linux-newbie-8/help-with-ls-lh-lhd-637515/)

laucian 04-24-2008 07:19 AM

help with ls -lh -lhd
 
hi everyone..i have this terminal window

Code:

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 ?

duryodhan 04-24-2008 07:43 AM

ls -d shows only directory entries which are always just 4K

laucian 04-24-2008 07:47 AM

thanks a lot..

indienick 04-24-2008 07:51 AM

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.


All times are GMT -5. The time now is 10:04 PM.