Setting creation or change timestamps

前端 未结 4 2127
旧时难觅i
旧时难觅i 2020-12-05 04:57

Using utimes, futimes, futimens, etc., it is possible to set the access and modification timestamps on a file.

Modification ti

4条回答
  •  猫巷女王i
    2020-12-05 05:44

    For ext2/3 and possibly for ext4 you can do this with debugfs tool, assuming you want to change the ctime of file /tmp/foo which resides in disk /dev/sda1 we want to set ctime to 201001010101 which means 01 January 2010, time 01:01:

    Warning: Disk must be unmounted before this operation

    # Update ctime
    debugfs -w -R 'set_inode_field /tmp/foo ctime 201001010101' /dev/sda1
    
    # Drop vm cache so ctime update is reflected
    echo 2 > /proc/sys/vm/drop_caches
    

    Information taken from Command Line Kung Fu blog.

提交回复
热议问题