您当前的位置:首页 > 计算机 > 系统应用 > Linux

Linux 上怎么看文件的创建时间

时间:12-14来源:作者:点击数:

总共分三步

stat 或者 ls -i 看 Inode

[root@host-192-168-111-31 rigaga]# stat rigaga.db.t.disk
  File: "rigaga.db.t.disk"
  Size: 40960     	Blocks: 80         IO Block: 4096   普通文件
Device: fd00h/64768d	Inode: 2237052     Links: 1
Access: (0644/-rw-r--r--)  Uid: (  496/  rigaga)   Gid: (  493/  rigaga)
Access: 2020-08-20 10:41:30.346011288 +0800
Modify: 2020-08-20 10:41:30.347011282 +0800
Change: 2020-08-20 10:41:30.347011282 +0800
[root@host-192-168-111-31 rigaga]# ls -i rigaga.db.t.disk
2237052 rigaga.db.t.disk

df 看 Filesystem

[root@host-192-168-111-31 ~]# df -h
Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root   37G  5.1G   31G  15% /
tmpfs                         939M   76K  939M   1% /dev/shm
/dev/vda1                     485M   35M  426M   8% /boot

debugfs 看 crtime

[root@host-192-168-111-31 ~]# debugfs -R 'stat <2237008>' /dev/mapper/VolGroup-lv_root
debugfs 1.41.12 (17-May-2010)
Inode: 2237008   Type: regular    Mode:  0644   Flags: 0x80000
Generation: 1528861317    Version: 0x00000000:00000001
User:   496   Group:   493   Size: 62181376
File ACL: 0    Directory ACL: 0
Links: 1   Blockcount: 121456
Fragment:  Address: 0    Number: 0    Size: 0
 ctime: 0x5f3de0bf:b66487f4 -- Thu Aug 20 10:32:31 2020
 atime: 0x5f3de0bf:b66487f4 -- Thu Aug 20 10:32:31 2020
 mtime: 0x5f3de0bf:b66487f4 -- Thu Aug 20 10:32:31 2020
crtime: 0x5f169e46:4aa00ec0 -- Tue Jul 21 15:50:30 2020
Size of extra inode fields: 28
EXTENTS:
(0-6): 8484871-8484877, (7-8): 8485002-8485003, (9): 8485100, (10): 8485198, (11-12): 8485264-8485265, (13): 8485292, (14-15): 8485294-8485295, (16-63): 8463984
-8464031, (64-127): 8464768-8464831, (128-255): 8465024-8465151, (256-511): 8467200-8467455, (512-1023): 8525824-8526335, (1024-2047): 8534016-8535039, (2048-40
95): 8536064-8538111, (4096-6143): 8560640-8562687, (6144-8191): 8591360-8593407, (8192-10239): 8613888-8615935, (10240-12287): 8644608-8646655, (12288-14335):
8652800-8654847, (14336-15180): 8677376-8678220

ctime 是文件修改(内容、权限、名称、位置等)时间,atime 是访问(读或写)时间,mtime 是文件内容修改时间,crtime 是文件创建时间。

  • ctime: Shows file change time. It is when the file's property changes. It will always be changed when the mtime changes, but also when you change the file's permissions, name or location.
  • atime: Shows file access time. It is updated when the file's contents are read by an application or a command such as grep or cat.
  • mtime: Shows file modification time. It is when the file was last modified. When you change the contents of a file, its mtime changes.
  • crtime: Shows file creation time.

The easiest way to remember which is which is to read their alphabetical order:

  1. atime can be updated alone
  2. ctime will update atime
  3. mtime will update both atime and ctime.
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门
本栏推荐