Modifying the mtime of a Linux file

Source: Internet
Author: User
Tags touch command

A. Linux file time Information

Files or folders in all UNIX file systems have three timestamps, atime, CTime, and Mtime, respectively.

    1. Atime indicates the time of the last access (only access, no changes) to the file;
    2. Mtime indicates the last time the file was modified;
    3. CTime indicates the last time the file attribute was changed, including permissions, size, attributes, and so on.

Difference:

Difference Atime Mtime CTime
Read or access files only (cat) Change Not change Not change
Modify File Contents Not necessarily (vim is not the same as Echo) Change Change
Modify File permission properties (Chmod,chown) Not change Not change Change

Two. How to view these time information

[Email protected]:~/test/20170224$ stat file1 File:'file1'Size: -Blocks:8IO Block:4096regular filedevice:fc00h/64512d Inode:1447275Links:1Access: (0644/-rw-r--r--) Uid: ( +/dill) Gid: (0/root) Access: 2017 - - style= "color: #800080" >24  16 : 22 : 59.158209413  + 0800  modify:  2017 -02 -  16 : 22 : 31.134761578  +0800  change:  2017 -02 -  16 : 22 : 31.134761578  +0800  Birth:-

Three. Modify Mtime

[Email protected]:~/test/20170224$ stat file1 File:'file1'Size: -Blocks:8IO Block:4096regular filedevice:fc00h/64512d Inode:1447275Links:1Access: (0644/-rw-r--r--) Uid: ( +/dill) Gid: (0/root) Access: .- Geneva- -  -: A:59.158209413+0800 Modify: ---£ º31.134761578 +   0800 Change : .- Geneva- -  -: A:31.134761578+0800Birth:-[email protected]-vm:~/test/20170224$touch-mt 1802241622  file1 [email protected]-vm:~/test/20170224$ stat file1 File:'file1'Size: -Blocks:8IO Block:4096regular filedevice:fc00h/64512d Inode:1447275Links:1Access: (0644/-rw-r--r--) Uid: ( +/dill) Gid: (0/root) Access: .- Geneva- -  -: A:59.158209413+0800 Modify:  2018-----£º 00.000000000 +  0800 Change : .- Geneva- -  -: +:21.319212091+0800Birth:-

The-m parameter refers to Mtime, and the next T and a bunch of numbers refer to the timestamp we want to change.

1802241622 delegates:

---> 2018

---> February

---> No. 24th

1622---> Time 16:22

Modify Mtime to current Linux time

[Email protected]:~/test/20170224$ stat file1 File:'file1'Size: -Blocks:8IO Block:4096regular filedevice:fc00h/64512d Inode:1447275Links:1Access: (0644/-rw-r--r--) Uid: ( +/dill) Gid: (0/root) Access: .- Geneva- -  -: A:59.158209413+0800Modify:2018- Geneva- -  -: A:00.000000000+0800Change : .- Geneva- -  -: +:21.319212091+0800Birth:-[email protected]-vm:~/test/20170224$ Touch file1 [email protected]-vm:~/test/20170224$ stat file1 File:'file1'Size: -Blocks:8IO Block:4096regular filedevice:fc00h/64512d Inode:1447275Links:1Access: (0644/-rw-r--r--) Uid: ( +/dill) Gid: (0/root) Access: .- Geneva- -  -: -:40.155812846+0800Modify: .- Geneva- -  -: -:40.155812846+0800Change : .- Geneva- -  -: -:40.155812846+0800Birth:-

The default behavior of the Touch command is to update the atime and mtime of a file to change to the current system time.

Resources

    1. How to update atime and mtime for file in Unix
    2. Linux files 3 point in time A_carat_tear

Modifying the mtime of a Linux file

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.