How to change only access time?

QuestionsQuestions8 SkillsProBasic Files OperationsSep, 19 2025
0152

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 -t option followed by the desired timestamp in the format [[CC]YY]MMDDhhmm[.ss]:
    touch -a -t 202301011200 example.txt
    This sets the access time to January 1, 2023, at 12:00 PM.

Using the -a option with touch allows you to specifically update the access time without affecting the modification time of the file.

0 Comments

no data
Be the first to share your comment!