Detailed explanation of file Time attribute in linux file system

Source: Internet
Author: User
Detailed description of linux file system: the file Time attribute file is the basic structure for storing data in linux. it is stored in storage media such as hard disk harddisk, CD, and floppy disk and named, this is the name of the file. Files in linux are non-structured streams. Linux has many... detailed description of linux file system: the file Time attribute file is the basic structure for storing data in linux. it is stored in storage media such as hard disk, CD, and floppy disk and is named, this is the name of the file. Files in linux are non-structured streams. There are many files in linux, which are managed and classified by inverted tree directory structure. A directory is an inverted tree structure that organizes and describes MetaData. The entire linux file system has a root/(root). when it is followed by a branch, the split plug can generate a branch, and the branch can also grow leaves. The root and fork are the directories in the linux file system, and the leaves are files. Access and operate files through the file path. Linux file Time attribute Overview after creating and modifying files and directories, their attributes will change, including the time attribute. You can use commands such as ls or stat to view the metadata of files and directories. The time attribute of a file is divided into three parts: file access time, modification time, and change. let's take a look at the specific situation under which the attribute changes. In linux, the time attribute of a file is represented by a struct. As follows: 011: struct stat {02 03 2: dev_t st_dev;/* device inode resides on */04 05 3: ino_t st_ino; /* inode's number */06 07 4: mode_t st_mode;/* inode's mode */08 09 5: nlink_t st_nlink; /* number of hard links to the file */10 11 6: uid_t st_uid;/* user ID of owner */12 13 7: gid_t st_gid; /* group ID of owner */14 15 8: dev_t st_rdev;/* device type, for special file inode */16 17 9: struct time Spec st_atimespec;/* time of last access */18 1910: struct timespec st_mtimespec;/* time of last data modification */20 2111: struct timespec st_ctimespec; /* time of last file status change */22 2312: off_t st_size;/* file size, in bytes */24 2513: int64_t st_blocks; /* blocks allocated for file */26 2714: u_int32_t st_blksize;/* optimal file sys I/O ops blocksize */28 2915: u_int32_t st_flags ;/* User defined flags for file */30 3116: u_int32_t st_gen;/* file generation number */32 3317 :}; linux file time attributes include access time, modification time modifed time, and change time. File access time when we create a file, the file has the same access time, modification time modifed time, change time. However, after some changes are made to the file, the time may change. File access time, that is, the file content is read. If the file is viewed, the file viewing time is updated. For example, after cat, more, and less operations, the file access time is updated. The following uses the ls command to view the file modification time by default. The modifed time command can be used to view more precise time attribute information. the file access time is 17:07:15. 000000000 + 0800. let's see the content of this file less. Exit After less. we can see that the access time attribute of this file has changed the file modification time. the modification time of the modifed time file is the modification time of the file content, for example, after modifying the file content through vim or emacs, or appending other methods, the modification time of the file changes. For the following example, the file content is modified through append, and the modification time of the file modifed time changes the file change time. change time: The change time of other attributes of the file. For example, the file access time is updated when the attributes of files (ignoring changes in the file access time attribute and file modification time attribute) are changed through chmod, chown, ln, and so on. The chmod and chown update files are brand new, and the ln update file's soft and hard link property information. The following example creates a hard link to change the file change time:
Related Article

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.