How to set the timestamp on a file to a time in the past using Linux and bash.

Posted: April 15, 2013. At: 10:03 PM. This was 5 years ago. Post ID: 5602
Page permalink: http://securitronlinux.com/bejiitaswrath/how-to-set-the-timestamp-on-a-file-to-a-time-in-the-past-using-linux-and-bash/

Now, we must convince Congress to stop the FCC. Can you display an alert?

This command will set the timestamp of a file in Linux to be in the past. I am not sure what use this is, but it shows what you can do with the Linux command line.

john@adeptus-mechanicus ~/Documents $ touch -t 200510071138 root.jpeg 
john@adeptus-mechanicus ~/Documents $ ls root.jpeg 
-rw-r--r-- 1 john john 385K  07-10-05 11:38 am root.jpeg

Or you can even set the timestamp to 1970.

john@adeptus-mechanicus ~/Documents $ touch -t 197010171138 root.jpeg 
john@adeptus-mechanicus ~/Documents $ ls root.jpeg 
-rw-r--r-- 1 john john 385K  17-10-70 11:38 am root.jpeg

Here to be a joker I am setting the timestamp of the file to 1885. This will be interesting.

john@adeptus-mechanicus ~/Documents $ touch -t 188501010800 root.jpeg 
john@adeptus-mechanicus ~/Documents $ ls root.jpeg 
-rw-r--r-- 1 john john 385K  01-01-85 08:00 am root.jpeg

Touch without any arguments will set the timestamp of the file to the current time. But with these examples I am showing that you can change the timestamp to something else.

No comments have been made. Use this form to start the conversation :)

Leave a Reply