[goto] Stat command output, access,modify,change meaning

Source: Internet
Author: User
Tags goto

Create a blank file first A.txt

1 [[email protected] tmp]$ toucha.txt
2
3 [[email protected] tmp]$ ls-al a.txt
4
5 -rw-rw-r-- 1 emduser emd 0 Dec 14 16:44 a.txt

Use the Stat command to view the various properties of a file a.txt
01 [[email protected] tmp]$ stat a.txt
02
03   File: `a.txt‘
04
05   Size: 0               Blocks: 0          IO Block: 4096   regular empty file
06
07 Device: fd00h/64768d    Inode: 654176      Links: 1
08
09 Access: (0664/-rw-rw-r--)  Uid: (  501/ emduser)   Gid: (  506/     emd)
10
11 Access: 2011-12-14 16:44:23.000000000 +0800
12
13 Modify: 2011-12-14 16:44:23.000000000 +0800
14
15 Change: 2011-12-14 16:44:23.000000000 +0800

The last three lines above have the following meanings:

Access: The last time a file was accessed

Modify: The last time the file content was modified

Change: File properties last changed time

    • If you use the Cat command to output the contents of the file A.txt to the terminal (perform cat a.txt), only a.txt access is refreshed.
    • If we append the current time to A.txt (execute date >> a.txt), then A.txt's modify and change are refreshed
    • If we change the A.txt to 777 (execute chmod 777 a.txt), then only a.txt changes are refreshed
    • If we use the VI command to open the file A.txt, and then save the exit, then A.txt access,modify and change are refreshed
PS: We can use command touch to update a.txt access and modify time, such as:
touch-d 1999-01-01 a.txt//change a.txt access and modify time to 1999-01-01 touch-a a.txt//change a.txt access time to current system time only touch-m A.txt Change the Modify time of A.txt to the current system time only
When we use Ls-l a.txt to see the time is modify time ps:http://unix.stackexchange.com/questions/2464/ Timestamp-modification-time-and-created-time-of-a-file

There is 3 kind of "timestamps":

    • Access-the last time the file was read
    • Modify-the last time the file is modified (content has been modified)
    • Change-the last time Meta data of the file was changed (e.g. permissions)

To display this information, you can use which are part of the stat coreutils.

statWould show you also some more information like the device, inodes, links, etc.

Remember that this is the sort of information depends highly on the filesystem and Mount options. For example if you mount a partition noatime with the option, no access information would be written.

A utility to change the timestamps would is touch . There is some arguments to decide which timestamp to change (e.g. a for access time,-m for modification time, etc.) and To influence the parsing of a new given timestamp. See for more man touch details.

touchcan become handy in combination with cp -u ("Copy if the SOURCE file is newer than the destination file or when The destination file is missing ") or for the creation of the empty marker files.

The field st_atime is changed by file accesses, for example, by Execve (2), Mknod (2), pipe (2),
Utime (2) and read (2) (of more than zero bytes). Other routines, like Mmap (2), may or could not update
St_atime.

The field st_mtime is changed by file modifications, for example, by Mknod (2), truncate (2), Utime (2)
and write (2) (of more than zero bytes). Moreover, st_mtime of a directory is changed by the creation
or deletion of files in the that directory. The St_mtime field is not changed for changes in owner,
Group, hard link count, or mode.

The field st_ctime is changed by writing or by setting inode information (i.e., owner, group, link
count, mode, etc.).

[goto] Stat command output, access,modify,change meaning

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.