Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

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.

share|improve this answer
1  
Nice answer, deserves to be top. –  Sean May 29 '12 at 15:05
    
Why is this functionality missing? –  Polyergic Sep 6 at 0:32

The what? The modified time is the time the file was last changed.

$ touch test
$ stat test
  File: `test'
  Size: 749             Blocks: 8          IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 33          Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/      me)   Gid: ( 1000/      me)
Access: 2012-03-06 18:43:19.000000000 -0600
Modify: 2012-03-06 18:43:19.000000000 -0600
Change: 2012-03-06 18:43:19.000000000 -0600
$ touch test
$ stat test
  File: `test'
  Size: 749             Blocks: 8          IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 33          Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/      me)   Gid: ( 1000/      me)
Access: 2012-03-06 18:43:23.000000000 -0600
Modify: 2012-03-06 18:43:23.000000000 -0600
Change: 2012-03-06 18:43:23.000000000 -0600
share|improve this answer
1  
when you type "stat filename" it presents you with 3 timestamps, Access, Modify and Change. "touch" only changes the first two of the three. –  Phillip Mar 6 '12 at 6:59
    
Not on my system: –  blujay Mar 7 '12 at 0:43
1  
if you run touch only, it will change the three time to the current time. However you can't specify as an arg the change time you want to set to a different intended value. –  Winston Dec 4 '12 at 0:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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