Files & folders

Linux touch command

Create an empty file, or update an existing file’s modification time.

Availability: Common Linux commands; shell built-ins and external implementations may differ by distribution.中文

Syntax

touch [OPTION]... FILE...

Examples

Create notes.txt if needed, or update its timestamps.

touch notes.txt

Copy source.txt timestamps to copy.txt.

touch -r source.txt copy.txt

Parameters, options and clauses

Option / clauseDescription
-aChange only the access time.
-mChange only the modification time.
-c, --no-createDo not create a missing file.
-d, --date=STRINGUse a parsed date/time instead of the current time.
-r, --reference=FILECopy timestamps from another file.
-t STAMPUse a timestamp in [[CC]YY]MMDDhhmm[.ss] format.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory