歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> Linux系統的文件時間屬性及touch命令

Linux系統的文件時間屬性及touch命令

日期:2017/3/3 16:16:39   编辑:關於Linux

Linux文件有三個時間屬性:

1)mtime:文件內容最後修改時間

2)ctime:文件狀態改變時間,如權限、屬性被更改

3)atime:文件內容被訪問時間,如cat,less等

在默認情況下,ls顯示出來的是該文件的mtime,即文件內容最後修改時間,如果你需要查看另外兩個 時間,可以加上--time參數,如下所示:

# ls -l /etc/man.config   
-rw-r--r--. 1 root root 4940 Feb 22  2013 /etc/man.config  
# ls -l --time ctime /etc/man.config   
-rw-r--r--. 1 root root 4940 Nov  5 20:14 /etc/man.config  
# ls -l --time atime /etc/man.config   
-rw-r--r--. 1 root root 4940 Dec 20 03:50 /etc/man.config

touch命令可以修改文件的時間,其用法如下:

如果沒有指定日期,默認為系統日期  
touch -d 18:03 file   
touch -d "18:03" file   
touch -d "6:03pm" file  
       
如果沒有指定時間,默認為 00:00:00  
touch -d 20000506 file   
touch -d "05/06/2000" file   
touch -d "20000506" file  
touch -d "6:03pm 05/06/2000" file   
touch -d "20000506 18:03" file   
touch -d "20000506 18:03:00" file

 

Copyright © Linux教程網 All Rights Reserved