To change only the access time of a file in Linux, you can use the touch command with the -a option. This option updates the access time (atime) of the specified file without modifying the modification time (mtime).
Command Syntax:
touch -a filename
Example:
To change the access time of a file named example.txt:
touch -a example.txt
Additional Options:
- If you want to set a specific access time, you can use the
-toption followed by the desired timestamp in the format[[CC]YY]MMDDhhmm[.ss]:
This sets the access time to January 1, 2023, at 12:00 PM.touch -a -t 202301011200 example.txt
Using the -a option with touch allows you to specifically update the access time without affecting the modification time of the file.
