touch Command Cheat Sheet
touch changes file timestamps. If the file doesn't exist, it creates an empty file.
Synopsis
touch [OPTION]... FILE...
Basic Usage
Create File / Update Time
touch file.txt
Managing Timestamps
Only Access Time (-a)
Update read time, keep modification time unchanged.
touch -a file.txt
Only Modification Time (-m)
Update modification time, keep access time unchanged.
touch -m file.txt
Specific Date/Time (-t)
Format: [[CC]YY]MMDDhhmm[.ss]
# Set to Dec 16, 2025 at 08:30
touch -t 202512160830 file.txt
Date String (-d)
Use human readable strings.
touch -d "next Thursday" file.txt
touch -d "2 hours ago" file.txt
touch -d "1 May 2024" file.txt
Reference File (-r)
Use another file's timestamp instead of current time.
touch -r reference.txt target.txt
Do Not Create (-c)
If file exists, update time. If not, do nothing (no new file).
touch -c missing_file.txt
Notes
- Makefiles:
touchis often used to "trick"makeinto thinking a file has been updated, forcing a recompile.