touch Command in Linux: Create Files and Update Timestamps

The touch command allows you to update the timestamps on existing files and directories as well as creating new, empty files.
This guide explains how to use the touch command through practical examples and detailed explanations of the most common command options.
touch Command Syntax
The general syntax for the touch command is:
touch [OPTIONS] FILE...Linux File Timestamps
Before going into how to use the touch command, let us start by reviewing the file timestamps in Linux.
A file in Linux has three timestamps:
- atime (access time) — The last time the file was accessed or opened by a command or application such as cat , vim, or grep .
- mtime (modify time) — The last time the file’s content was modified.
- ctime (change time) — The last time the file’s attributes or content changed. Attributes include file permissions, ownership, or location.
To display the file status including all timestamps, use the stat
command:
stat file_nameCreating a new file requires write permissions on the parent directory. Otherwise, you will receive a permission denied error.
How to Use the touch Command
In its simplest form, when used without any options, if the file specified as an argument does not exist, touch will create a new empty file.
If the file already exists, touch will change the file’s last access and modification times to the current time.
For example, if file1 does not exist, the following command will create it; otherwise, it will update its timestamps:
touch file1To create or update multiple files at once, specify the file names as arguments:
touch file1 file2 file3If you do not want the touch command to create new files, use the -c (--no-create) option.
For example, if file1 exists, the following command will update its timestamps; otherwise, it will do nothing:
touch -c file1Changing Only the Access or Modification Time
By default, if no option is used, touch will update both the access and modification times to the current time. Using the -a and -m options, you can change only one of these timestamps.
Change Only the Access Time
Use the -a option to change only the file’s access time:
touch -a file1Change Only the Modification Time
Use the -m option to change only the file’s modification time:
touch -m file1When changing the modification time, the change time (ctime) will also be updated. If you also need to manage permissions while updating timestamps, see the chmod command guide .
Setting Specific Timestamps
The touch command also allows you to update or create a file with a specific time other than the current time.
Use the -d (--date=) option to specify a date string:
touch -d '1 June 2018 11:02' file1The date string must be enclosed in single or double quotes.
You can also provide a partial date-time string. Providing only the date uses midnight as the time:
touch -d '12 June' file1Use the -t option to specify a timestamp in the following format:
[[CC]YY]MMDDhhmm[.ss]For example, the following command sets the access and modification times of file1 to June 1st, 11:02, of the current year:
touch -t 06011102 file1Using the Timestamp of Another File
The -r (--reference=) option allows you to specify a reference file and use its timestamps instead of the current time.
For example, the following command sets the timestamps of file2 to match those of file1:
touch -r file1 file2Changing Symbolic Link Timestamps
By default, using touch on a symbolic link
changes the timestamps of the file it points to, not the symlink itself.
Use the -h (--no-dereference) option to modify the timestamp of the symlink:
touch -h symlink1Quick Reference
| Command | Description |
|---|---|
touch file | Create empty file or update timestamps |
touch file1 file2 | Create or update multiple files |
touch -c file | Update timestamps only, do not create |
touch -a file | Update access time only |
touch -m file | Update modification time only |
touch -d 'DATE' file | Set specific date and time |
touch -t MMDDhhmm file | Set timestamp in numeric format |
touch -r ref file | Copy timestamps from a reference file |
touch -h symlink | Update symlink timestamp, not target |
Troubleshooting
“Permission denied” when creating a file
You need write permission on the directory where you are creating the file. Check permissions with ls -ld /path/to/directory and use sudo if necessary.
Timestamps not updating (noatime filesystem)
Some filesystems are mounted with the noatime option for performance. In this case, touch -a will update atime in memory but it may not be written to disk. Check mount options with findmnt.
Cannot set ctime directly
The ctime (change time) cannot be set manually — it is always updated by the kernel when file metadata or content changes. Only atime and mtime can be set with touch.
FAQ
What is the difference between atime, mtime, and ctime?atime is updated when the file is read, mtime is updated when the file content changes, and ctime is updated when any metadata (permissions, ownership) or content changes. Only atime and mtime can be set directly with touch.
Does touch update ctime?
Yes, indirectly. Any time touch updates atime or mtime, the kernel also updates ctime because the file metadata has changed. You cannot set ctime to a custom value.
Can I use touch to create a file with content?
No, touch only creates empty files or updates timestamps. To create a file with content, use redirection or a text editor
.
How do I check a file’s timestamps after using touch?
Use the stat
command: stat filename. It shows the full access, modify, and change timestamps.
Does touch work on directories?
Yes. Running touch dirname updates the access and modification times of the directory itself, the same way it does for files.
Conclusion
The touch command is a simple but versatile utility for creating empty files and managing file timestamps in Linux. If you have any questions, feel free to leave a comment below.
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page