what does "total" mean in ls -al
Great question, it means you want to pay attention to detail. I'll illustrate with examples. Under my home directory /home/el
there is a directory called tmpdir with files underneath it. I change to that directory and do ls -al
el@angeliqe ~/tmpdir $ ls -al
total 20
drwxrwxr-x 4 el users 4096 Dec 21 11:45 .
drwx--x--x 9 el users 4096 Dec 21 11:45 ..
drwxrwxr-x 2 el users 4096 Dec 21 11:45 dirWithFiles
drwxrwxr-x 2 el users 4096 Dec 21 11:44 emptydir
-rw-rw-r-- 1 el users 182 Dec 21 11:45 myfile.txt
It says 'total 20'. That translates to: "tmpdir uses 20K of space on disk for all of the directories and files".
with the -h option, you tell it to give it to you in human readable form:
el@angeliqe ~/tmpdir $ ls -alh
total 20K
drwxrwxr-x 4 el users 4.0K Dec 21 11:45 .
drwx--x--x 9 el users 4.0K Dec 21 11:45 ..
drwxrwxr-x 2 el users 4.0K Dec 21 11:45 dirWithFiles
drwxrwxr-x 2 el users 4.0K Dec 21 11:44 emptydir
-rw-rw-r-- 1 el users 182 Dec 21 11:45 myfile.txt
It is interesting to note that a directory with nothing in it also takes up 8K space, in my case emptydir
has nothing in it but shows as using 8K
el@angeliqe ~/tmpdir/emptydir $ ls -al
total 8
drwxrwxr-x 2 el users 4096 Dec 21 11:44 .
drwxrwxr-x 4 el users 4096 Dec 21 11:45 ..
Adding an empty directory proves that directories take up 4K:
el@angeliqe ~/tmpdir/emptydir $ ls -alh
total 12K
drwxrwxr-x 3 el users 4.0K Dec 21 11:54 .
drwxrwxr-x 4 el users 4.0K Dec 21 11:45 ..
drwxrwxr-x 2 el users 4.0K Dec 21 11:54 blah
Another command to investigate is du
:
el@angeliqe ~/tmpdir/emptydir $ du
4 ./blah
8 .
Also, you can look at file sizes to a certain depth:
el@angeliqe ~ $ du -h --max-depth=1
12K ./.ssh
4.0K ./my_recycle_bin
8.0K ./.vim
13G ./gnuoctbluehost
24K ./tmpdir
48K ./.subversion
152K ./.cpan
13G .
el@angeliqe ~ $