Full time information and three time attributes for viewing files under Linux

Source: Internet
Author: User
Tags aliases

I. Full time information for viewing files under Linux

1. When viewing files under Linux, the ls–l default is not to display seconds:
# ls-l/etc/total 0-rw-r--r--.  1 root root Jan 5 09:43 adjtime-rw-r--r--. 1 root root 1518 June 7 aliases


2, to display the second (actually more accurate), you can use the –full-time parameter:
# ls-l/etc/--full-timetotal 0-rw-r--r--.  1 root root 2018-01-05 09:43:59.352996227 +0800 adjtime-rw-r--r--. 1 root root 1518 2013-06-07 22:31:32.000000000 +0800 aliases


3. To display more information, use the STAT command:

# stat/etc/adjtime File: '/etc/adjtime ' size:16 blocks:8 IO block:4096 regular Filedevice: fd00h/64768d inode:8483789 links:1access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root) Context : system_u:object_r:adjtime_t:s0access:2018-01-05 09:48:18.965219287 +0800modify:2018-01-05 09:43:59.352996227 + 0800change:2018-01-05 09:43:59.352996227 +0800 Birth:-


Ii. three time attributes for Linux files

1, under Linux , a file also has three kinds of time attributes:

Access time, modification time, state change time.


There is no concept of creation time under Linux , that is, it is not possible to know when a file was established, but

If the file has not been modified after the establishment, the modification time = establishment time;

If the file is established, the state is not changed, then the state change time = settling time;

If the file is not read after it is established, then the access time = settling time, because it is not good to judge whether the file has been changed, read, and its status is changed, so it is almost impossible to determine the file settling time.


The three time attributes for Linux files are:

Atime, an abbreviation for access time, shows the time at which the data in the file was last accessed and the contents of the file are read once, and the time is updated. For example, it is used directly by the process of the system or indirectly through some commands and scripts. (Execute some executables, scripts) or use more, cat, and more commands for this file. LS, stat command does not modify the file access time

Mtime, the abbreviation for modify time (modified), shows the last time when the contents of a file are changed, such as when editing with VI (that is, the contents of the block), ls-l the time listed is this time.

CTime, which is the abbreviation for change time (state churn), displays the file's permissions, the owner, the group to which the link number changes, and the time it was changed. Of course, when content changes, it also changes. (That is, the inode content changes and block content changes), the chmod, chown command to modify the file attributes, the time will be updated.


2. The commands to view the file three times are:

2.1. ls command

ls -lc filename  list files  ctimels -lu filename  list files  atimels  -l   filename    list  mtime fields for files              Description                                               examples                         ls (-L) st_atime     Last access time for file data                 read                        -ust_mtime   last modified time for file data                 write                         default st_ctime    file data last change time                chown,chmod         -c


2.2. UseStatcommand to see the file for three different times:
# stat anaconda-ks.cfg   file:  ' Anaconda-ks.cfg '   Size: 1862             Blocks: 8           IO Block: 4096   regular fileDevice:  Fd00h/64768d    inode: 16797762    links: 1access (permissions):  (0600/-RW-------)   Uid:  (    0/    root)     Gid:  (    0/    root) context (Environment):  system_u:object_r: Admin_home_t:s0access (last visited):  2018-01-05 09:44:50.567995756 +0800modify (Last modified):  2018-01-05  09:44:50.569995756 +0800change (Last modified):  2018-01-05 09:44:50.569995756 +0800 birth (creation time): -  Description: Access time for access. Modify modification time. Change state changes time. You can stat * view the status of all files in this file/directory. Because the Anaconda-ks.cfg file has not been changed in content, property, and has not read this file, so the three (visitTime, modification time, state change time) is consistent, when the file modification time is the same as these three times, there is no doubt. 


Full time information and three time attributes for viewing files under Linux

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.