您现在的位置是:首页 > 电脑 > 

linux 修改文件日期,Linux系统如何修改文件的时间

2025-07-24 06:27:32
Linux系统文件创建的时间并不是不能修改的,通过touch命令可以修改文件的时间,从而达到以假乱真的效果。下面就来介绍一下Linux系统如何修改文件的时间。 关于touch命令的描述: -d, --date=STRIG parse STRIG and use it instead of current time

Linux系统文件创建的时间并不是不能修改的,通过touch命令可以修改文件的时间,从而达到以假乱真的效果。下面就来介绍一下Linux系统如何修改文件的时间。

关于touch命令的描述:

-d, --date=STRIG

parse STRIG and use it instead of current time

touch的参数说明:

命令参数:

-a 或--time=atime或--time=access或--time=use  只更改存取时间。

-c 或--no-create  不建立任何文档。

-d 使用指定的日期时间,而非现在的时间。

-f 此参数将忽略不予处理,仅负责解决BSD版本touch指令的兼容性问题。

-m 或--time=mtime或--time=modify  只更改变动时间。

-r 把指定文档或目录的日期时间,统统设成和参考文档或目录的日期时间相同。

-t 使用指定的日期时间,而非现在的时间。

--no-create 不会建立新档案。

--help 列出指令格式。

--version 列出版本讯息。

此处就使用简单的修改文件时间。

实例:将系统里某些文件修改为三个月前的时间:

当前系统文件信息如下:

࿻root@case test࿽# ls -l

total 28

drwxr-xr-x 2 root root 4096 Jan 9 15:47 1

-rwxrwxr-x 1 oracle oinstall 814 Jan 9 14:41 .sh

drwxr-xr-x 2 root root 4096 Jan 9 15:49 444

-rw-r--r-- 1 root root 0 Jan 9 14:41 4.sh

-rwxr-xr-x 1 root root 814 Jan 9 14:44 77.sh

-rwxrwxr-x 1 root root 54 Jan 9 16:0 find.sh

把所有的.s件修改到三个月前(2015年10月1)的时间。操作命令:

࿻root@case test࿽# touch -d “10/1/201” *.sh

结果是:

࿻root@case test࿽# ls -l

total 28

drwxr-xr-x 2 root root 4096 Jan 9 15:47 1

-rwxrwxr-x 1 oracle oinstall 814 Oct 1 00:00 .sh

drwxr-xr-x 2 root root 4096 Jan 9 15:49 444

-rw-r--r-- 1 root root 0 Oct 1 00:00 4.sh

-rwxr-xr-x 1 root root 814 Oct 1 00:00 77.sh

-rwxrwxr-x 1 root root 54 Oct 1 00:00 find.sh

另外也可以单独修改时间或者月份,如下

以使用 am, pm 或是 24 小时的格式,日期可以使用其他格式如 6 May 2000 。

touch -d “6:0pm” file

touch -d “05/06/2000” file

touch -d “6:0pm 05/06/2000” file

以上就是Linux系统修改文件的时间的方法了,这样一来不管是用户查看,还是系统识别的文件的创建时间都可以被改成几个月以前的了。

#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格

本文地址:http://www.dnpztj.cn/diannao/157477.html

相关标签:无
上传时间: 2023-05-03 15:21:46
留言与评论(共有 5 条评论)
本站网友 早产儿奶粉
29分钟前 发表
0pm 05/06/2000” file 以上就是Linux系统修改文件的时间的方法了,这样一来不管是用户查看,还是系统识别的文件的创建时间都可以被改成几个月以前的了
本站网友 韩式隆胸术
26分钟前 发表
49 444 -rw-r--r-- 1 root root 0 Oct 1 00
本站网友 中国移动广东
11分钟前 发表
0pm 05/06/2000” file 以上就是Linux系统修改文件的时间的方法了,这样一来不管是用户查看,还是系统识别的文件的创建时间都可以被改成几个月以前的了
本站网友 who是什么意思
4分钟前 发表
00 find.sh 另外也可以单独修改时间或者月份,如下 以使用 am, pm 或是 24 小时的格式,日期可以使用其他格式如 6 May 2000