LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-05-2006, 11:56 PM   #1
greeting
LQ Newbie
 
Registered: Jun 2006
Posts: 17

Rep: Reputation: 0
Angry I don't understand how to calculate the total value of (ls -l)


Hi! Everybody

I don't know the calculation of total in ls -l command.
total 60
-rw------- 1 user1 user1 1317 Aug 3 17:17 anaconda-ks.cfg
drwxr-xr-x 3 user1 user1 4096 Aug 3 17:40 Desktop
-rw-r--r-- 1 user1 user1 28324 Aug 3 17:13 install.log
-rw-r--r-- 1 user1 user1 4151 Aug 3 17:12 install.log.syslog

If I use the command ls -l in the empty dirctory I got the total of 0.(easy to understand )
total 0

If I use the command ls -al in the empty dirctory I got the total of 16. (How???)
total 16
drwxrwxr-x 2 user1 user1 4096 Aug 6 09:06 .
drwxrwxr-x 4 user1 user1 4096 Aug 6 09:06 ..

Regards,
Greeting
 
Old 08-06-2006, 12:07 AM   #2
DrAxeman
Member
 
Registered: Jun 2004
Location: State of Confusion
Distribution: My other OS is your Solaris box.
Posts: 84

Rep: Reputation: 15
Great question. I'm not sure either. Maybe it's the total # of inodes used?

Does anyone have a better answer?
 
Old 08-06-2006, 12:32 AM   #3
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Debian, FreeBSD
Posts: 1,450

Rep: Reputation: 48
Code:
     The listing of a directory's contents is preceded by a labeled total num-
     ber of blocks used in the file system by the files which are listed as
     the directory's contents (which may or may not include . and .. and other
     files which start with a dot, depending on other options).

     The default block size is 512 bytes.
This is from the FreeBSD manpage but it still looks to be the same.
Code:
drwxrwxr-x 2 user1 user1 4096 Aug 6 09:06 .
drwxrwxr-x 4 user1 user1 4096 Aug 6 09:06 ..
4096 is 8 512 byte blocks.
.=8 +
..=8
Total=16

Code:
-rw------- 1 user1 user1 1317 Aug 3 17:17 anaconda-ks.cfg
drwxr-xr-x 3 user1 user1 4096 Aug 3 17:40 Desktop
-rw-r--r-- 1 user1 user1 28324 Aug 3 17:13 install.log
-rw-r--r-- 1 user1 user1 4151 Aug 3 17:12 install.log.syslog
1317 = 3 blocks
4096 = 8 blocks
28324 = 56 blocks
4151 = 9 blocks

Total = 76 ? This is odd though. I don't know why that worked out like it did. Oh well, that is what the number is supposed to mean.

Last edited by frob23; 08-06-2006 at 12:33 AM.
 
Old 08-06-2006, 12:38 AM   #4
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Debian, FreeBSD
Posts: 1,450

Rep: Reputation: 48
It occurs to me that the number of blocks used would be less than the bytes in a file if the file had a hole in it. It's possible for me to create a file which should be 137 blocks but only uses 6 because most of the file is a hole. That is probably the case in the above example. I suspect install.log has a hole which threw off the numbers.
 
Old 08-06-2006, 02:03 AM   #5
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Ubuntu/WSL
Posts: 9,786

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
The same question was recently discussed:
http://www.linuxquestions.org/questi...d.php?t=455323

You can investigate the sparse file theory by using the "du install.log" command.
 
Old 08-08-2006, 02:48 AM   #6
greeting
LQ Newbie
 
Registered: Jun 2006
Posts: 17

Original Poster
Rep: Reputation: 0
Talking install.log

First of all, I would like to say thank you for paying attention to my thread. I tried du command for the following lines

-rw------- 1 user1 user1 1317 Aug 3 17:17 anaconda-ks.cfg
drwxr-xr-x 3 user1 user1 4096 Aug 3 17:40 Desktop
-rw-r--r-- 1 user1 user1 28324 Aug 3 17:13 install.log
-rw-r--r-- 1 user1 user1 4151 Aug 3 17:12 install.log.syslog


And I got the results like the following

[root@linux ~]# du install.log.syslog
12 install.log.syslog
[root@linux ~]# du install.log
32 install.log
[root@linux ~]# du anaconda-ks.cfg
8 anaconda-ks.cfg

Now, total of 60 is clear.



I would like to know more about total of ls -l. And I have tested the following...

[root@linux mydir]# touch one
[root@linux mydir]# touch two
[root@linux mydir]# touch three
[root@linux mydir]# ls -l
total 12
-rw-r--r-- 1 root root 0 Aug 8 11:43 one
-rw-r--r-- 1 root root 0 Aug 8 11:43 three
-rw-r--r-- 1 root root 0 Aug 8 11:43 two
[root@linux mydir]# du one
4 one
[root@linux mydir]# du three
4 three
[root@linux mydir]# du two
4 two


[root@linux mydir]# cat >> one
one
ls

[root@linux mydir]# ls -l
total 16
-rw-r--r-- 1 root root 7 Aug 8 11:45 one
-rw-r--r-- 1 root root 0 Aug 8 11:43 three
-rw-r--r-- 1 root root 0 Aug 8 11:43 two

[root@linux mydir]# du one
8 one

1. Linux uses 4 blocks for empty files????
2. Linux uses 8 blocks for non-empty files???

Thank in advance,
Greeting
 
Old 08-12-2006, 02:11 AM   #7
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Ubuntu/WSL
Posts: 9,786

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
What filesystem are you using ?
 
Old 08-12-2006, 05:28 AM   #8
jp-lack
Member
 
Registered: Mar 2005
Location: NJ - US
Distribution: Slackware
Posts: 93

Rep: Reputation: 15
you can use 'h' for human readable

root@zion:~# ls -lh
total 28M
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
calculate the RTT of a datagram trscookie Linux - Networking 6 04-06-2006 06:33 AM
How do you calculate (manually) 2 to the power 3.5? davee General 11 11-05-2004 11:22 AM
function to calculate maximum value suchi_s Programming 5 10-26-2004 10:38 AM
Calculate the space of a folder Half_Elf Linux - General 4 05-18-2003 07:53 PM
calculate traffic using iptables p_nanda2002 Linux - Software 4 11-01-2002 02:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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

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