What is "total" in the output of "ls" command?

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)?

Asked By: g4ur4v

||

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
Answered By: jofel

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.

Answered By: doneal24

total count of blocks, it includes also indirect blocks.

Answered By: b3h3m0th
Categories: Answers Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.