hosting image

How to modify the timestamp of files in Linux

Summery :
The “-t” option modifies the time stamp of the file and the format is YYYYMMDDHHMM. The time stamp is changed to current system date and time after touch command is run with ‘-m’ option.
as example if we got a file called tcp.php

executing the command

$ stat tcp.php



Access: 2022-7-6 21:58:21 
Modify: 2022-7-6 21:58:21


then :

touch -a -m -t 19770707 sec4ever.php


will change timestamp to 07/07/1977 to touch a file with specific time :

$ touch -d "1977-07-07 12:12:12" tcp.php


additionally we can copy other file timestamp by using this command:

touch a.php -r b.php


Leave a Reply

Your email address will not be published. Required fields are marked *