An interesting question: ls, an interesting question: ls
When we use the ls-l command, we will see the following similar information.
Many people may not be very concerned about the value of total 12 in the first line, but have you ever wondered what it means?
Man, we can see that total means"The total disk space used by the listed content and the value. Unit: kbytes"
What does this sentence mean?
We know that the value of column 5th listed in ls-l is the size of the file or directory. The directory size is not the total size of the files contained in the directory. It is only the size of the Directory itself.
If you cannot understand this concept, please think about it"Everything in linux is a file"The meaning of this sentence.
That is to say, the total 12 k in the figure should be equal to the value of 767 + 4096 + 4096. Let's calculate and see if this is the case.
767 + 4096 + 4096 = 8959 the unit here is bytes, so if we convert it to k, the value is 8959/1024 = 8.74902 k.
Obviously, 12 ≤ 8.74902
But why is total "the total disk space used by the listed content and the value. "? Note the word "occupied". What is occupied?
We know that a file system has the concept of block. A block is like a room. If you have to store large files in the file system, therefore, using a large block will produce better performance, and vice versa.
The block size occupied by data during storage is the space occupied.
So how many blocks does 8.74902 occupy?
Let's take a look at the size of the block in the system. There are two ways to view this information. :
As a result, the size of a block in the system is 4 kb. So how many blocks does 8.74902k occupy?
It apparently occupies three blocks. Although only 0.74902k data is stored in the third block, it still occupies one block space.
So the occupied space displayed by total is 3 * block = 3*4 k = 12 k
Do you understand?