How to set a file's ctime with Python? [duplicate] How to set a file's ctime with Python? [duplicate] unix unix

How to set a file's ctime with Python? [duplicate]


It is relatively trivial to set a files ctime to the current time. Just modify its mtime, flip a permission bit or even make a hardlink to it. It is, AFAIK, impossible to set a file's ctime to an arbitrary value using the system call API in any direct sort of way.

If you had root access you could set the system time, do something to the file to set the ctime to the current time, then set the system time back. Also you could bit-twiddle the inode data structure on disk. But both of these are really bad ideas for a whole host of reasons that I don't expect I should have to explain in detail.