Linux atime CTime mtime

Source: Internet
Author: User
Tags touch command

Touch Testtime

1, stat testtime "for file name" can see this file name of the three states

2, ll Testtime;ll--time=atime testtime; ll--time=ctime Testtime

-rw-r--r--. 1 root root 0 Sep 19:28 testtime
-rw-r--r--. 1 root root 0 Sep 19:28 testtime
-rw-r--r--. 1 root root 0 Sep 19:28 testtime

3, vi, inside write content

ll Testtime;ll--time=atime testtime; ll--time=ctime Testtime

-rw-r--r--. 1 root root 6 Sep 19:29 testtime
-rw-r--r--. 1 root root 6 Sep 19:29 testtime
-rw-r--r--. 1 root root 6 Sep 19:29 testtime "Change the content, causing all three to change"

4, date, Ah, time has changed.

Then chmod 777 Testtime

ll Testtime;ll--time=atime testtime; ll--time=ctime Testtime

-rwxrwxrwx. 1 root root 6 Sep 19:29 testtime
-rwxrwxrwx. 1 root root 6 Sep 19:29 testtime
-rwxrwxrwx. 1 root root 6 Sep 19:31 testtime "Change permissions cause CTime to change"

5, has a VI, changed the content

-rwxrwxrwx. 1 root root Sep 19:33 testtime
-rwxrwxrwx. 1 root root Sep 19:33 testtime
-rwxrwxrwx. 1 root root (SEP) 19:33 Testtime "All three have changed."

6. Cat Testtime look inside your content

ll Testtime;ll--time=atime testtime; ll--time=ctime Testtime

-rwxrwxrwx. 1 root root Sep 19:33 testtime
-rwxrwxrwx. 1 root root Sep 19:34 testtime "only atime change"
-rwxrwxrwx. 1 root root Sep 19:33 testtime

--------------------------------------------

Summarize:

Mtime (Modification time): When a file is written with changes to the contents of the file. The time we see with Ls-l is mtime.

CTime: Is the time that is changed when you write to a file, change the owner, permission, or link settings with the contents of the inode. Equivalent to the time seen by Ls-l–time=ctime "Change permissions this time change"

Atime (Access time): When the file is read or when it is executed. That is, the time "cat looks at the file, this time changes" with Ls-l–time=atime.

"Change the contents of the document" All three have changed

Example two:
One

Ll/etc/issue;ll--time=atime/etc/issue; ll--time=ctime/etc/issue

-rw-r--r--. 1 root root 2013/etc/issue
-rw-r--r--. 1 root root (SEP) 19:07/etc/issue
-rw-r--r--. 1 root root (June) 04:26/etc/issue

Second, revise the time

Touch-t 0807151313/etc/issue "Change issue file date to 2008/07/15 13:13"

Third, view

Ll/etc/issue;ll--time=atime/etc/issue; ll--time=ctime/etc/issue

-rw-r--r--. 1 root root 2008/etc/issue
-rw-r--r--. 1 root root 2008/etc/issue "atime and Mtime changed, and CTime changed."
-rw-r--r--. 1 root root (SEP) 19:46/etc/issue "CTime changed to the current time"

---------------------------

Example four:

(1) About LS command

Ls-l default viewing time is Mtime

LS-LC Viewing Files CTime

Ls-lu Viewing Files Atime

Like downloading a rpm file.

Ls-l Mtime for RPM package creation time

LS-LC CTime for rpm package download time

Ls-lu Atime for RPM package access time

(2), about Touch command

-A modifies the file's access time and modifies the CTime to the current time,-a defaults to the current time for the file to be modified, and other times to be used with parameters such as-t or-D.

-M modifies the modification time of the file and modifies the CTime to the current times, using the same method as-a.

Modify CTime to a specific time method: First modify the system time for the CTime time you want to set, and then touch-a or touch-m Modify, CTime with change to the current system time.

(3), other

VI edit save will be modified at the same time three times

(4) Chgrp, Chown, chmod and other orders will change the CTime, but Atime, mtime unchanged.

Linux atime CTime mtime

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.