6

How to change files CREATION time? I tried to use 'touch' command but it changes only the last modified time - it does not change the first date - creation date. (After checking by 'stat' it still shows me the original file creation date)

Is there any option to do this?

thanks in advance

  • 3
    Are you sure you mean the creation (aka birth) time? Few systems make that information available. Maybe you're thinking of the ctime (change time) – Stéphane Chazelas Jan 10 '17 at 13:25
  • 1
    touch newfile; cat oldfile > newfile; mv newfile oldfile – Shadur Jan 10 '17 at 16:02
3

In linux, there is no creation time, there are only access, modify, and change dates. The POSIX standard only defines three distinct timestamps to be stored for each file: the time of last data access, the time of last data modification, and the time the file status last changed. Linux does not provide a kernel API for accessing the file creation times, even on filesystems supporting them (ext4, Btrfs and JFS), perhaps it will be impelemented in the future.

To modifie the accessed and modified time in a file, you can use the command touch with these options

-a = accessed
-m = modified
2

There is no way that creation time (btime) and change time(ctime) can be faked.

The only trick i could suggest you is to put back your system data, touch the file then get back "in the future".

  • 1
    @StephenKitt, in any case neither the ctime (change time) nor btime (birth/creation time where available) can be faked other than by using file system debuggers or changing the system clock. – Stéphane Chazelas Jan 10 '17 at 13:28
  • @StéphaneChazelas I know, see unix.stackexchange.com/a/316387/86440 – Stephen Kitt Jan 10 '17 at 13:29
  • 1
    No need to downvote, it was just a typo. Edited. – Alessandro Rossi Jan 10 '17 at 14:00
0

You have to backup the file, delete it, then move the backup back in place, in order to modify the creation date in the inode.

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