An interesting question: ls, an interesting question: ls

Source: Internet
Author: User

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?

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.