Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
ls command: what does the first line mean?

I have an empty directory.I am using following command to view the contents of that directory.

ls -lart

The output I get is below.

total 12
drwxr-xr-x 5 root  root  4096 Oct  2 12:26 ..
drwxr-xr-x 2 apx   aim   4096 Nov 29 18:40 .

I don't have any files in this directory,then what counts out to 12 here ( total 12 ) ?

share|improve this question

marked as duplicate by Gilles, Renan, warl0ck, Mat, jasonwryan Nov 30 '12 at 7:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 5 down vote accepted

That is the total number of blocks taken up by the files, although I would expect the total to be 8 instead of 12 (using 1k blocks). Try ls -as1 to see the size in blocks of each file.

share|improve this answer
This is the output I get... total 12 4 drwxr-xr-x 5 root root 4096 Oct 2 12:26 .. 8 drwxr-xr-x 2 apx aim 4096 Nov 29 18:40 . – g4ur4v Nov 29 '12 at 14:00

The "total" is the disk usage of listed files (because of -a including the . and .. entries) in blocks (1024 bytes or if POSIXLY_CORRECT is set in 512 bytes), not including the content of subdirectories.

If same files are not referenced and therefore listed twice (hard-links), you can get the same output with

du -Ss

or in human readable units

du -Ssh
share|improve this answer
No, ls just adds up the disk usage of the files listed (so . and .. are included only if -a is included), and contrary to du, ls doesn't account for hardlinks, so the result will be different. -a, -A (GNU), -L at least will affect the value reported. Also note that with GNU ls, the value will be different if POSIXLY_CORRECT is in the environment (block size 512) or not (block size 1024) – Stéphane Chazelas Nov 29 '12 at 13:54
Thanks Stephane Chazelas for your comment. I improved my answer. As GNU's du react also on POSIXLY_CORRECT, it should use the same block size. – jofel Nov 29 '12 at 14:27

total count of blocks, it includes also indirect blocks.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.