touch
file managementLinux/Unix
The touch command is one of the most frequently used commands in Linux/Unix-like operating systems. touch Change file timestamps or create empty files
Quick Reference
Command Name:
touch
Category:
file management
Platform:
Linux/Unix
Basic Usage:
touch filename.txt
Common Use Cases
Syntax
touch [OPTION]... FILE...
Options
Option | Description |
---|---|
-a |
Change only the access time |
-c, --no-create |
Do not create any files |
-d, --date=STRING |
Parse STRING and use it instead of current time |
-f |
(Ignored) Historic option for compatibility |
-h, --no-dereference |
Affect each symbolic link instead of any referenced file (useful only on systems that can change the timestamps of a symlink) |
-m |
Change only the modification time |
-r, --reference=FILE |
Use this file's times instead of current time |
-t STAMP |
Use [[CC]YY]MMDDhhmm[.ss] instead of current time |
--time=WORD |
Change the specified time: WORD is access, atime, or use (same as -a); WORD is modify or mtime (same as -m) |
--help |
Display help and exit |
--version |
Output version information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the touch
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
# Create a new empty file
touch new_file.txt