Skip to content

How to change the file timestamp on Linux

This tip might comes handy when you do a system check and you want to make sure you don’t check the same file twice.

Let’s pretend that our “file1” is a conf file that needs review. As you can see the output of the command issued below shows that the file was last edited in June.
Today I want to check the file without editing it and make sure next time I won’t check it again:

Touch is an excellent tool in this case:

The Modification Time has changed and so has the access time.

If you want to change just the modification time leaving the access time untouched try with the -m option

And -a is just for the Access Time.

Another interesting option is -t. It lets you set the time and the date with whatever you like. This is often used to do fishy things 🙂

comments powered by Disqus