Posted: . At: 10:03 PM. This was 11 years ago. Post ID: 5602
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.

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

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.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.