An interesting question: what exactly is total in the content displayed by Ls-l?

Source: Internet
Author: User

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.