mtime,ctime,atime

なんだかよくわからなくなったので、言葉の整理。。。

名称 説明 詳細
mtime 修正時間(iノード管理) 指定日数内に修正、更新されたファイル
ctime 作成時間 指定日数内に属性変更されたファイル
atime アクセス時間 指定日数内にアクセスされたファイル


確認方法

ls -l で mtimeを確認できる
ls -lc でctimeを確認できる
ls -lu でatimeを確認できる

# touch m.txt
# touch c.txt
# touch a.txt


ls -l で mtimeを確認できる

# ls -l
合計 0

  • rw-r--r-- 1 root root 0 8月 25日 01:33 a.txt
  • rw-r--r-- 1 root root 0 8月 25日 01:33 c.txt
  • rw-r--r-- 1 root root 0 8月 25日 01:33 m.txt


ls -lc でctimeを確認できる

# ls -lc
合計 0

  • rw-r--r-- 1 root root 0 8月 25日 01:33 a.txt
  • rw-r--r-- 1 root root 0 8月 25日 01:33 c.txt
  • rw-r--r-- 1 root root 0 8月 25日 01:33 m.txt


ls -lu でatimeを確認できる

# ls -lu
合計 0

  • rw-r--r-- 1 root root 0 8月 25日 01:33 a.txt
  • rw-r--r-- 1 root root 0 8月 25日 01:33 c.txt
  • rw-r--r-- 1 root root 0 8月 25日 01:33 m.txt


atime,mtimeはtouchコマンドで変更可能
=>任意の時間に変更可能

# touch -a a.txt
# touch -m m.txt


ctimeはchmodコマンドを使用して変更できる。
=> ただし、現在時にのみ変更*1となってしまう。

chmod c.txt

*1:システム時刻を変更すれば任意の時間に変更できてしまうけれど。。。