How to change ‘change’ date of file

filestimestamps

How can I change the "change" date of a file? Using touch doesn't work:

$ touch -t 9901010000 test;stat test
  File: `test'
  Size: 0           Blocks: 0          IO Block: 4096   regular empty file
Device: fe01h/65025d    Inode: 11279017    Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/    x)   Gid: ( 1000/    x)
Access: 1999-01-01 00:00:00.000000000 +0100
Modify: 1999-01-01 00:00:00.000000000 +0100
Change: 2012-04-08 19:26:56.061614473 +0200
 Birth: -

Best Answer

You cannot change the ctime by ordinary means. This is by design: the ctime is always updated to the current when you change any of the file's metadata, and there is no way to impose a different ctime. To change the ctime of a file, you need to do one of the following:

  • Set the system time to the ctime you want to impose, then touch the file, then reset the system time.
  • Modify the kernel to add an interface to change the ctime.
  • Access the disk image directly (e.g. with debugfs) and twiddle the bits on the disk (don't do it while the filesystem is mounted).
Related Question