5

I know you can use "touch" to change the access and modify timestamps of a file using the "-t" flag but is it possible to change the "change" timestamp. If so how would I go about doing this? Thanks so much for your time.

1 Answer 1

8

You're asking how to set the ctime value of a file. The only way to do that is to change the system date and then change the file, which is quite a crude method that will probably cause harm to the rest of your system.

If you're using ext3 (maybe ext2 and ext4 also?) you can use debugfs to change it, but that requires that you unmount the filesystem first. You can find info at COMMAND LINE KUNG FU: Episode #80: Time Bandits (the start is about Windows; skip about halfway down to "Hal has the touch") to read about commands like this: debugfs -w -R 'set_inode_field /tmp/test ctime 200901010101' /dev/mapper/elk-root

Without using filesystem metadata hackery like that, you can't do it.

2
  • 1
    Nice answer, deserves to be top.
    – Sean
    May 29, 2012 at 15:05
  • Why is this functionality missing? Sep 6, 2014 at 0:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.