linux修改文件ctime_Linux查看和修改文件时间

参考http://www.361way.com/chang-file-time/1632.html

一:查看时间

1:查看文件的具体时间信息

File: `probn‘ Size: 2 Blocks: 8 IO Block: 4096regular file

Device: 803h/2051d Inode: 913948 Links: 1Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/root)

Access:2016-10-31 20:00:00.000000000 +0800Modify:2016-10-31 20:00:00.000000000 +0800Change:2016-10-31 15:22:32.020285558 +0800

Access:访问时间    cat more less

Modify:修改内容时间    vim

Change:修改文件属性的时间   chmod

2:用ls的方法查看

Access time   访问时间     :atime

ls -l --time=atime kkk

Modification time 修改时间:mtime  ls -l查看的时候默认的就是修改时间

ls -l

status time   状态时间      :ctime

ls -l --time=ctime kkk

二:修改文件的时间

touch 命令:

touch 一个已经存在的文件,只会修改时间

-a 修改文件的访问时间

[root@yunovo allapk]# touch -a -d "2009-11-11"kkk

[root@yunovo allapk]# stat kkk

File: `kkk‘ Size: 0 Blocks: 0 IO Block: 4096regular empty file

Device: 803h/2051d Inode: 913948 Links: 1Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/root)

Access:2009-11-11 00:00:00.000000000 +0800Modify:2016-10-31 09:00:00.000000000 +0800Change:2016-10-31 15:55:30.295285265 +0800

-m 修改文件的修改时间

[root@yunovo allapk]# touch -m -d "2010-10-18"kkk

[root@yunovo allapk]# stat kkk

File: `kkk‘ Size: 0 Blocks: 0 IO Block: 4096regular empty file

Device: 803h/2051d Inode: 913948 Links: 1Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/root)

Access:2009-11-11 00:00:00.000000000 +0800Modify:2010-10-18 00:00:00.000000000 +0800Change:2016-10-31 15:56:11.510285082 +0800

-d 同时修改访问时间和修改时间

[root@yunovo allapk]# touch -d "2008-10-10"kkk

[root@yunovo allapk]# stat kkk

File: `kkk‘ Size: 0 Blocks: 0 IO Block: 4096regular empty file

Device: 803h/2051d Inode: 913948 Links: 1Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/root)

Access:2008-10-10 00:00:00.000000000 +0800Modify:2008-10-10 00:00:00.000000000 +0800Change:2016-10-31 15:54:00.235285047 +0800

3:把后面文件夹的时间修改成和前一个文件一样,change这个时间还是自己的

touch -acmr kkk lll

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值