小品Linux檔案時間

來源:互聯網
上載者:User


小品Linux檔案時間 在Linux相關崗位的面試中,經常會問到文檔時間的問題。
Linux文檔的時間一般分三種:Access time-atime(訪問時間)、
Modification time-mtime(內容修改時間)、status-ctime(狀態時間)  www.2cto.com  
 mtime可以通過ls -l命令顯示,表示文檔內容最後被修改的時間。atime可以通過ls -lu命令顯示,表示文檔最後被訪問的時間。ctime可以通過ls -lc命令顯示,表示文件屬性最後被修改的時間。 樣本說明,以下樣本均已Ubuntu 10.04.4為操作平台:----------------------------------------------------------------------------Jacob@server01:~/test$ date                                 #顯示目前時間為09:29 Tue Dec  4 09:29:35 CST 2012  Jacob@server01:~/test$ touch test.txt                       #建立空白檔案test.txt  Jacob@server01:~/test$ ls -l                                #查看檔案mtime為09:29 -rw-r--r-- 1 Jacob Jacob 0 2012-12-04 09:29 test.txt  Jacob@server01:~/test$ ls -lu                               #查看檔案atime為09:29 -rw-r--r-- 1 Jacob Jacob 0 2012-12-04 09:29 test.txt  Jacob@server01:~/test$ ls -lc                               #查看檔案ctime為09:29 -rw-r--r-- 1 Jacob Jacob 0 2012-12-04 09:29 test.txt 說明:檔案被常見是所有時間均為建立檔案的初始時間。----------------------------------------------------------------------------Jacob@server01:~/test$ date                                 #查看目前時間為09:31 Tue Dec  4 09:31:10 CST 2012  Jacob@server01:~/test$ echo "abc" > test.txt                #修改檔案內容為abc  Jacob@server01:~/test$ ls -l                                #查看檔案mtime為09:31 -rw-r--r-- 1 Jacob Jacob 0 2012-12-04 09:31 test.txt  Jacob@server01:~/test$ ls -lc                               #查看檔案ctime為09:31,檔案內容修改的同時,檔案屬性發生了變化 -rw-r--r-- 1 Jacob Jacob    4 2012-12-04 09:31 test.txt  Jacob@server01:~/test$ ls -lu -rw-r--r-- 1 Jacob Jacob    4 2012-12-04 09:29 test.txt      #查看檔案atime為09:29 ---------------------------------------------------------------------------- Jacob@server01:~/test$ date                                 #查看目前時間為09:33 Tue Dec  4 09:33:44 CST 2012  Jacob@server01:~/test$ chmod a+x test.txt                   #修改檔案屬性 Jacob@server01:~/test$ ls -l -rwxr-xr-x 1 Jacob Jacob 4 2012-12-04 09:31 test.txt        #查看檔案mtime為09:31  Jacob@server01:~/test$ ls -lu -rwxr-xr-x 1 Jacob Jacob 4 2012-12-04 09:29 test.txt        #查看檔案atime為09:29  Jacob@server01:~/test$ ls -lc -rwxr-xr-x 1 Jacob Jacob 4 2012-12-04 09:33 test.txt        #查看檔案ctime為90:33 -----------------------------------------------------------------------------Jacob@server01:~/test$ date                                 #查看目前時間為90:35 Tue Dec  4 09:35:03 CST 2012  Jacob@server01:~/test$ cat test.txt                         #查看訪問檔案內容 abc  Jacob@server01:~/test$ ls -l                                #查看檔案mtime為09:31 -rwxr-xr-x 1 Jacob Jacob 4 2012-12-04 09:31 test.txt  Jacob@server01:~/test$ ls -lu -rwxr-xr-x 1 Jacob Jacob 4 2012-12-04 09:35 test.txt        #查看檔案atime為09:35   Jacob@server01:~/test$ ls -lc -rwxr-xr-x 1 Jacob Jacob 4 2012-12-04 09:33 test.txt        #查看檔案ctime為09:33  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.