A. Linux file time Information
Files or folders in all UNIX file systems have three timestamps, atime, CTime, and Mtime, respectively.
- Atime indicates the time of the last access (only access, no changes) to the file;
- Mtime indicates the last time the file was modified;
- 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
- How to update atime and mtime for file in Unix
- Linux files 3 point in time A_carat_tear
Modifying the mtime of a Linux file