Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How can I change 'change' date?

$ 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: -
share|improve this question
    
Setting arbitrary ctime is not easy to do. Related question on SO. –  jw013 Apr 8 '12 at 19:38
add comment

3 Answers

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).
share|improve this answer
add comment

The ctime of a file is updated when any of the metadata is changed.

$ ls -l x.py
-rw-rw-r--. 1 ignacio ignacio 485 Mar 26  2010 x.py
$ stat -c %z x.py
2010-03-26 11:57:56.237068175 -0400
$ chown ignacio x.py
$ stat -c %z x.py
2012-04-08 15:31:33.682383575 -0400
$ ls -l x.py
-rw-rw-r--. 1 ignacio ignacio 485 Mar 26  2010 x.py
share|improve this answer
    
but how modify it without update it –  Someone1234 Apr 8 '12 at 20:11
add comment

You have the answer on related SO question pointed by jw013, for extX, on unmounted disk :

# 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
share|improve this answer
add comment

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.