Change the UNIX & Linux File Time Stamp

The touch command is used to change file timestamps, change the access and/or modification times of the specified files. Follow steps and command to change a file time stamp under UNIX or Linux operating system.

1. As an example, list all the files using ls -l to find the time stamp of the listed files.

# ls -l | more
-rw-r–r–    1 root          525 Jan 30  2011 1012 etc.conf
-rw-r–r–    1 root          525 Jan 30  2011 1130 testfile.txt

2. From the list, you can see the time stamp for testfile.txt is on 30 January 2011 at 1130pm. So, we are gonna change the testfile.txt time stamp into current date and time.

# touch -t 201102011045 testfile.txt
# ls -l | more
-rw-r–r–    1 root          525 Jan 30  2011 1012 etc.conf
-rw-r–r–    1 root          525 Feb 01  2011 1045 testfile.txt

Additional note:
• 2011: Year, 02: Month, 01: Date, 1045: Time

You May Also Like

Leave a Reply?