LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   du -h vs ls -la (https://www.linuxquestions.org/questions/linux-newbie-8/du-h-vs-ls-la-433595/)

p_test 04-10-2006 02:49 AM

du -h vs ls -la
 
Hi

I created a directed u directory X. I entered the dir with #cd x
- Then i did #ls -la
The first line with the . entry was showing the size
to be 1024.
- But when i did #du -h /x it was giving 2k...

Both the cases are showing the size of the same dir..but the r not the same.... why is the diff there.... am i reght assuming that both should be exactly the same...

Regards

MasterC 04-10-2006 03:23 AM

Try removing the -h option, then you might be able to get a better idea. ls -la is showing you both the . and the above directory .., and totalling the 2.

Here's what I get (I use 4k blocks):

Code:

mkdir word
[masterc@masterc ~]$ cd word/
[masterc@masterc word]$ ls -lha
total 8.0K
drwxrwxr-x  2 masterc masterc 4.0K Apr 10 02:22 .
drwxr-xr-x  68 masterc masterc 4.0K Apr 10 02:22 ..
[masterc@masterc word]$ ls -la
total 8
drwxrwxr-x  2 masterc masterc 4096 Apr 10 02:22 .
drwxr-xr-x  68 masterc masterc 4096 Apr 10 02:22 ..
[masterc@masterc word]$ du -h
4.0K    .
[masterc@masterc word]$ du
4      .
[masterc@masterc word]$

HTH

Cool


All times are GMT -5. The time now is 01:23 AM.