When we use the ls-l command, we see a similar message like the following.
Many people may not be very concerned about the value of total 12 in the first row, but do you ever wonder what it means?
As explained in man, we can see that total means "the sum of the disk footprint values for the listed content." Unit is Kbytes"
What do you mean by this sentence?
We know that the 5th column value listed in Ls-l is the size of the file or directory. The size of the directory here is not the total size of the files that the directory contains. But only the size of the directory itself.
If you don't understand this concept, consider the meaning of the phrase "everything in Linux ".
So, the total 12k in the figure should be equal to the value of 767+4096+4096. Let's calculate and see if that's the case.
767+4096+4096=8959 so the unit here is of course bytes, so we convert to K, then the value is 8959/1024=8.74902k
So apparently 12≠8.74902
But why total is "the sum of the disk footprint values for the listed content." "? Please note that the "occupancy" of the word, what is the occupation?
We know that there is a block concept in the file system, blocks are like a room, and if you have a file system with some large files, then using a larger block will get better performance and vice versa.
Then the size of the block that the data occupies during the storage process is the "Occupy" space.
So how many blocks does 8.74902 occupy?
We still have to look at how big the block in the system is. There are two ways to view it. :
So we know that 1 blocks in the system have 4k. So how many blocks does 8.74902k occupy?
It is clear that 3 blocks are occupied, although only 0.74902k of data is stored in the third block, but it still occupies a block space. 、
So the total is shown to occupy space is 3*block = 3*4k = 12k
Do you get it?
An interesting question: what exactly is total in the content displayed by Ls-l?