Touch (Set file modified date)

Chester Wyke June 02, 2022 Updated: April 15, 2025 #debian

Source: https://www.thegeekstuff.com/2012/11/linux-touch-command/

Command

touch -t [[CC]YY]MMDDhhmm[.SS]

The following explains the above format:

Example

touch -t 202101291605.09 foo.txt
stat foo.txt

2 Digit year defaults

If the value of the YY is between 70 and 99, then value of the CC digits is assumed to be 19.

If the value of the YY is between 00 and 37, then value of the CC digits is assumed to be 20.

NB: It is not possible to set the date beyond January 18, 2038.