Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[SOLVED] du -h vs ls -h

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
banderas20
Posts: 111
Joined: 2016-11-10 15:30

[SOLVED] du -h vs ls -h

#1 Post by banderas20 »

Hello,

i am at the root of the filesystem.

If I run "du -h -d 1", I get

Code: Select all

56K	./root
870M	./var
686M	./home
3.7G	./usr
du: cannot access './run/user/1000/gvfs': Permission denied
41M	./run
9.7M	./bin
du: cannot access './proc/14174/task/14174/fd/4': No such file or directory
du: cannot access './proc/14174/task/14174/fdinfo/4': No such file or directory
du: cannot access './proc/14174/fd/3': No such file or directory
du: cannot access './proc/14174/fdinfo/3': No such file or directory
0	./proc
8.0K	./mnt
16K	./lost+found
8.0K	./media
8.8M	./etc
4.0K	./opt
4.0K	./.cache
8.0K	./srv
0	./sys
9.4M	./sbin
376K	./tmp
34M	./boot
0	./dev
233M	./lib
4.0K	./lib64
5.6G	.
Wich matches with the free space given by "df" command.

However, if i run "la -lah", i get only a bunch of KB:

Code: Select all

drwxr-xr-x  23 root root 4.0K Jul 22 13:24 .
drwxr-xr-x  23 root root 4.0K Jul 22 13:24 ..
drwxr-xr-x   2 root root 4.0K Jul  1 20:06 bin
drwxr-xr-x   3 root root 4.0K Jul  1 20:07 boot
drwx------   2 root root 4.0K Jun 18 20:44 .cache
drwxr-xr-x  17 root root 3.1K Jul 19 09:57 dev
drwxr-xr-x 126 root root  12K Jul 23 15:20 etc
drwxr-xr-x   4 root root 4.0K Jul  5 18:28 home
lrwxrwxrwx   1 root root   29 Jun 18 20:23 initrd.img -> boot/initrd.img-4.9.0-6-amd64
lrwxrwxrwx   1 root root   29 Jun 18 20:23 initrd.img.old -> boot/initrd.img-4.9.0-6-amd64
drwxr-xr-x  15 root root 4.0K Jun 18 20:43 lib
drwxr-xr-x   2 root root 4.0K Jun 18 20:23 lib64
drwx------   2 root root  16K Jun 18 20:22 lost+found
drwxr-xr-x   3 root root 4.0K Jun 18 20:22 media
drwxr-xr-x   3 root root 4.0K Jul  1 20:07 mnt
drwxr-xr-x   2 root root 4.0K Jun 18 20:23 opt
dr-xr-xr-x 183 root root    0 Jul 19 09:56 proc
drwx------   5 root root 4.0K Jul  2 18:54 root
drwxr-xr-x  27 root root  820 Jul 23 15:21 run
drwxr-xr-x   2 root root 4.0K Jul 19 10:10 sbin
drwxr-xr-x   3 root root 4.0K Jul  2 19:06 srv
dr-xr-xr-x  13 root root    0 Jul 23 15:22 sys
drwxrwxrwt  17 root root 4.0K Jul 23 15:39 tmp
drwxr-xr-x  10 root root 4.0K Jun 18 20:23 usr
drwxr-xr-x  12 root root 4.0K Jul  1 13:39 var
lrwxrwxrwx   1 root root   26 Jun 18 20:23 vmlinuz -> boot/vmlinuz-4.9.0-6-amd64
lrwxrwxrwx   1 root root   26 Jun 18 20:23 vmlinuz.old -> boot/vmlinuz-4.9.0-6-amd64
¿Why is that so? ¿Shouldn't they match?

Thanks!
Last edited by banderas20 on 2018-07-23 15:04, edited 1 time in total.

arzgi
Posts: 1197
Joined: 2008-02-21 17:03
Location: Finland
Been thanked: 31 times

Re: du -h vs ls -h

#2 Post by arzgi »

Try:

Code: Select all

df -h

banderas20
Posts: 111
Joined: 2016-11-10 15:30

Re: du -h vs ls -h

#3 Post by banderas20 »

arzgi wrote:Try:

Code: Select all

df -h
df -h matshes with the result of du. But why ls gives me only a bunch ok KB? That command is also meant to count the size of files and folders.....

Thanks.

arzgi
Posts: 1197
Joined: 2008-02-21 17:03
Location: Finland
Been thanked: 31 times

Re: du -h vs ls -h

#4 Post by arzgi »

banderas20 wrote:
arzgi wrote:Try:

Code: Select all

df -h
df -h matshes with the result of du. But why ls gives me only a bunch ok KB? That command is also meant to count the size of files and folders.....

Thanks.
Read man page, if you want to know what command is meant to do.

Dai_trying
Posts: 1101
Joined: 2016-01-07 12:25
Has thanked: 6 times
Been thanked: 16 times

Re: du -h vs ls -h

#5 Post by Dai_trying »

man df wrote:NAME
df - report file system disk space usage
man du wrote:NAME
du - estimate file space usage
man ls wrote:NAME
ls - list directory contents
The above should answer your question, but each of these commands can give different output depending on the parameters you pass to it.

ls simply lists directory contents (without additional parameters) and so would not normally show directory size information.

banderas20
Posts: 111
Joined: 2016-11-10 15:30

Re: du -h vs ls -h

#6 Post by banderas20 »

Dai_trying wrote:
ls simply lists directory contents (without additional parameters) and so would not normally show directory size information.
I understand, but I don't get what those sizes beside the date mean....

arzgi
Posts: 1197
Joined: 2008-02-21 17:03
Location: Finland
Been thanked: 31 times

Re: du -h vs ls -h

#7 Post by arzgi »

banderas20 wrote:
Dai_trying wrote:
ls simply lists directory contents (without additional parameters) and so would not normally show directory size information.
I understand, but I don't get what those sizes beside the date mean....
Size of file, and directories always 4,0K

banderas20
Posts: 111
Joined: 2016-11-10 15:30

Re: du -h vs ls -h

#8 Post by banderas20 »

arzgi wrote:
banderas20 wrote:
Dai_trying wrote:
ls simply lists directory contents (without additional parameters) and so would not normally show directory size information.
I understand, but I don't get what those sizes beside the date mean....
Size of file, and directories always 4,0K
Mistery solved then. Thanks! :D

Dai_trying
Posts: 1101
Joined: 2016-01-07 12:25
Has thanked: 6 times
Been thanked: 16 times

Re: du -h vs ls -h

#9 Post by Dai_trying »

A link only shows the size of the link by default, although you can pass a parameter to change this effect.
try this

Code: Select all

ls -laLh
It will not work for directories but I usually use ncdu to traverse the file structure with the sizes displayed, it does take a minute or so to load up with the information but is very handy sometimes.

Post Reply