3 time-point resolution for viewing files in Linux with the stat command

Source: Internet
Author: User
Tags touch command

There are times when we need to use the Stat command to view the details of a file. In addition, Lenovo, Ls-l command shows what time, Touch command to modify the timestamp of the file, the change is what time? Here we're going to test it together.

First, let's take a look at stat status.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/58/17/wKioL1So93qD3jDBAAEhdyaEVwY678.jpg "title=" Stat command. jpg "alt=" wkiol1so93qd3jdbaaehdyaevwy678.jpg "/>

, there will be 3 types of time, namely Access,modify,change. We will explain these 3 times in detail below.

Access time: Indicates when we last visited (only access, no changes) files

Modify Time: Indicates when we last modified the file

Change Time: Indicates the date when we last changed the properties of a file, including permissions, size, attributes, and so on.

For example, we use the Cat command to view the following file:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/58/1B/wKiom1So976A45N_AAE4z3X4VsY398.jpg "title=" Access.png "alt=" Wkiom1so976a45n_aae4z3x4vsy398.jpg "/>

At this point, the access time for the file has been modified. Access time we can understand the last time we accessed a file.


Let's take a look at the change time situation:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/58/1B/wKiom1So-JPxm5ijAAD93WKlMEk653.jpg "title=" Change.png "alt=" Wkiom1so-jpxm5ijaad93wklmek653.jpg "/>

At this point, when we modify the properties of the file and so on, the change time changes, but the modify time is constant, because we do not modify the contents of the file.


Now let's look at the Modify time:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/58/1B/wKiom1So-VCTorFNAADbC8ts5k4777.jpg "title=" Modify.png "alt=" Wkiom1so-vctorfnaadbc8ts5k4777.jpg "/>

At this point we can see that 3 of the time points have changed.

Thus, we can know

1, when we just read the file, access time changes, and Modify,change does not change

2, Access,modify,change time will change when the file is modified

3, when the file attributes are modified, change time changes, while access,modify is unchanged.


So, what time do we use the command ls-l to show? When did touch modify the timestamp of the file?

Let's keep looking.

Ls-l the time displayed

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/58/18/wKioL1So_M-TjmxpAAK3qMH1xs4964.jpg "title=" ls.png "alt=" Wkiol1so_m-tjmxpaak3qmh1xs4964.jpg "/> At this point, the comparison can be found, ls-l display time is the modification time of the file.



Finally, what time does touch change?

First we look at Touch's man help to help me find the answer.


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/58/18/wKioL1So_bfgyKYTAAGkcY_pqyM374.jpg "title=" Touch.png "alt=" Wkiol1so_bfgykytaagkcy_pqym374.jpg "/>

If you don't believe us, we'll try again. (However, if you do not add parameters, all the time will be modified.) In the man touch, there is a-a parameter that modifies access time only. This parameter can be tested on your own. )

Let's touch b.txt directly, because the B.txt file already exists, and it doesn't create a new but modifies its timestamp.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/58/18/wKioL1So_tGyeqOVAAGI5K5AxYg128.jpg "title=" Touch1.jpg "alt=" Wkiol1so_tgyeqovaagi5k5axyg128.jpg "/> At this point, I think we should figure out the timing of these commands. Do not understand can leave a message we discuss.

Caishuxueqian, there is the wrong place also ask the big God pointing. Learn from each other.




This article is from "Linux rookie" blog, please be sure to keep this source http://ludihua.blog.51cto.com/4601284/1599040

3 time-point resolution for viewing files in Linux with the stat command

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.