How to change the UNIX Birth Time of a file
Note that ctime
is NOT the Creation Time, but the Change Time. The Creation Time is really called the Birth Time.
Not all filesystems store the birth time. POSIX only mandates to store ctime
, mtime
and atime
. Some filesystems do store the btime
, see a comparison of filesystem metadata here.
To view the different time entries, use stat(1):
$ stat -f "Access (atime): %Sa%nModify (mtime): %Sm%nChange (ctime): %Sc%nBirth (Btime): %SB" GF\ Meeting\ KW01.md
Access (atime): Jan 6 14:41:14 2023
Modify (mtime): Jan 4 18:00:00 2023
Change (ctime): Jan 6 14:41:13 2023
Birth (Btime): Jan 4 18:00:00 2023
To change, use touch(1):
$ touch -t 202301041800 file.txt
This will change the birth time, iff the time given is before the current birth time.
See discussion on SO here.