Parsing at three time points when using the stat command to view files in Linux

Source: Internet
Author: User
Tags touch command

Parsing at three time points when using the stat command to view files in Linux

Sometimes, we need to use the stat command in Linux to view the detailed information of the file. In addition, what time is displayed by the ls-l command, the time stamp of the File Modified by the touch command, and the time when the file was modified? Here we will test it together.

Stat -- get more information than ls

First, let's look at the stat situation.

, Three types of time are displayed: Access, Modify, and Change. Next we will explain in detail these three times.

Access time: indicates the time when we last accessed (only accessed, not changed) the file.

Modify time: indicates the time when the last file was modified.

Change time: The last time we changed the file attributes, including permissions, size, and attributes.

For example, run the cat command to view the file:

The access time of the file is modified. We can understand the access time as the last time we accessed the file.

Let's take a look at the change time:

At this point, when we modify the attributes of a file, the change Time will change with the modification time, but the modify time will not change because we did not modify the file content.

Next we will look at the modify time:

Now we can see that all three time points have changed.

From this, we can know

1. When we only read the file, the access time changes, while the modify and change time do not change.

2. When the file is modified, access, modify, and change time will change accordingly.

3. When modifying the file properties, the change time changes, while the access and modify time remain unchanged.

So what time is ls-l displayed? When touch modifies the file timestamp, what time does it modify?

Let's continue.

Ls-l display time

In this case, we can see that the ls-l display time is the file modification time.

Finally, what time does touch modify?

First, let's take a look at touch's man help to help me find the answer.

If you don't believe it, try again. (However, if no parameter is added, all the time will be modified. There is a-a parameter in man touch, and only the access time is modified. You can try this parameter by yourself .)

We directly touch B .txtbar, because the B .txt file already exists, instead of creating a new one, we modify its timestamp.

At this point, I think you should have understood the timing of these commands. If you don't understand it, leave a message to discuss it.

If something is wrong, please kindly advise. Learn from each other.

This article permanently updates the link address:

Related Article

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.