What is the total
in the output of ls -l
?
$ ls -l /etc
total 3344
-rw-r--r-- 1 root root 15276 Oct 5 2004 a2ps.cfg
-rw-r--r-- 1 root root 2562 Oct 5 2004 a2ps-site.cfg
drwxr-xr-x 4 root root 4096 Feb 2 2007 acpi
-rw-r--r-- 1 root root 48 Feb 8 2008 adjtime
drwxr-xr-x 4 root root 4096 Feb 2 2007 alchemist
Just to mention - you can use -h (ls -lh) to convert this in human readable format.
You can find the definition of that line in the
ls
documentation for your platform. Forcoreutils
ls
(the one found on a lot of Linux systems), the information can be found viainfo coreutils ls
:That is the total number of file system blocks, including indirect blocks, used by the listed files. If you run
ls -s
on the same files and sum the reported numbers you'll get that same number.The Formula: What is that number?
Why so confusing?
This number is fairly detached from any physical or meaningful metric. Many junior programmers haven't had experience with file holes or hard/sym links. In addition, the documentation available on this specific topic is virtually non-existent.
The disjointedness and ambiguity of the term "block size" has been a result of numerous different measures being easily confused, and the relatively deep levels of abstraction revolving around disk access.
Examples of conflicting information:
du
(orls -s
) vsstat
Running
du *
in a project folder yields the following: (Note:ls -s
returns the same results.)Total: 2+2+1+3+3+5+26+4+2+14 = 62 Blocks
Yet when one runs
stat
we see a different set of values. Runningstat
in the same directory yields:Total: 3+3+1+5+6+10+51+8+3+28 = 118 Blocks
There are two important things takeaways:
stat
reports both thephysical_blocks_in_use
andphysical_block_size
as used in the formula above. Note that these are values based on OS interfaces.du
is providing what is generally accepted as a fairly accurate estimate of physical disk utilization.For reference, here is the
ls -l
of directory above: