Using utimes
, futimes
, futimens
, etc., it is possible to set the access and modification timestamps on a file.
Modification time is the last time the file data changed. Similarly, "ctime" or change time, is the last time attributes on the file, such as permissions, were changed. (Linux/POSIX maintains three timestamps: mtime and ctime, already discussed, and 'atime', or access time.)
Is there a function to set change timestamps? (Where "change" is the attribute modification or 'ctime', not modification time 'mtime'.) (I understand the cyclic nature of wanting to change the change timestamp, but think archiving software - it would be nice to restore a file exactly as it was.)
Are there any functions at all for creation timestamps? (I realize that ext2
does not support this, but I was wondering if Linux did, for those filesystems that do support it.)
If it's not possible, what is the reasoning behind it not being so?
If you want to change the last modified date or change the file creation data, press to enable the Modify date and time stamps checkbox. This will enable you to change the created, modified, and accessed timestamps—change these using the options provided.
Timestamps are records for the times in which actions are performed on files. A timestamp is useful because it keeps records of when a file was accessed, modified, or added. Linux's files have 3 timestamps recorded by the computer: Access timestamp (atime): which indicates the last time a file was accessed.
The “-t” option modifies the time stamp of the file and the format is YYYYMMDDHHMM. The time stamp is changed to current system date and time after touch command is run with '-m' option.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With