Set file create date Unix command that I could use

Asked By 20 points N/A Posted on -
qa-featured

I'm new to Unix. Is there a set file create date Unix command that I could use? Is it possible to set file create date in Unix manually and not automatically from the system time? Thank you.

SHARE
Answered By 0 points N/A #134631

Set file create date Unix command that I could use

qa-featured

Hello,

1.In unix nearest to file creation date is last modified date of the inode.
    ls -ladc old_file
    However, this date is not reliable and can be changed due to various softwares and chmod.

2. The file creation date ( or the ctime) is not really the creation date in unix, it is the last time the inode data and some other metadata was modified.
    chmod modifies ctime. assume the file is -rwxr-xr-x (755) then
    
    chmod 755 filename  # You must be the owner of the file.

    This will set ctime to present .Linux chattr command can also change the ctime.

3. If you want to change the last modification/last access date, you can use the touch command as follows:
    
    touch new_file # It will change the current modification time to current date and time
    
        touch -t 8002041406 old_file  # It sets the modification time of old-file to 14:06 on February 4, 1980.    
    
    touch -r old_file new_file # It sets the modification time of new file to that of old file.

4. The file creation date is the one you cannot change with the touch command.   

Related Questions