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 create 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 standard 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.
Most modern filesystems, such as ext4, XFS, and Btrfs, also record a birth (creation) time, but the touch command cannot change it.
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 file3To create a numbered set of files, use Bash brace expansion:
touch file{1..5}.txtThe shell expands file{1..5}.txt to file1.txt file2.txt file3.txt file4.txt file5.txt and passes all five names to touch.
If 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 file1Whichever timestamp you change, the change time (ctime) is also updated to the current time. 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 2026 11:02' file1The date string must be enclosed in single or double quotes.
To verify the new timestamps, run stat on the file:
stat file1 File: file1
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 253,1 Inode: 262163 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/linuxize) Gid: ( 1000/linuxize)
Access: 2026-06-01 11:02:00.000000000 +0000
Modify: 2026-06-01 11:02:00.000000000 +0000
Change: 2026-10-14 20:43:43.598013715 +0000
Birth: 2026-10-14 20:43:43.597007826 +0000The Access and Modify lines show the date we passed to -d. The Change line shows the current time. The kernel updates ctime every time touch changes the other timestamps. Birth is the time the file was created.
You can also provide a partial date-time string. Providing only the date uses midnight as the time:
touch -d '12 June' file1The -d option accepts the same free-form date strings as the date command
. This includes relative values such as yesterday or 2 days ago:
touch -d '2 days ago' file1Use the -t option to specify a timestamp in the following format:
[[CC]YY]MMDDhhmm[.ss]Each field is a two-digit number:
CC- The first two digits of the yearYY- The last two digits of the yearMM- The month (01-12)DD- The day of the month (01-31)hh- The hour (00-23)mm- The minutes (00-59)ss- The seconds (00-59)
The fields in square brackets are optional. If you leave out the year, touch uses the current year, and without .ss, the seconds are set to zero.
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 file1To set the year and seconds as well, use the full form. The following command sets the timestamps to June 1st, 2026, 11:02:30:
touch -t 202606011102.30 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 file2You can combine -r with a relative -d value to shift the time. The following command sets the timestamps of file2 to one hour earlier than those of file1:
touch -d '-1 hour' -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 -d '2 days ago' file | Set a relative date |
touch -t MMDDhhmm file | Set timestamp in numeric format |
touch -r ref file | Copy timestamps from a reference file |
touch -d '-1 hour' -r ref file | Shift timestamps relative to 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.
“No such file or directory” when creating a file
The touch command does not create parent directories. If newdir does not exist, touch newdir/file1 fails with cannot touch 'newdir/file1': No such file or directory. Create the directory first with mkdir -p
, then run touch again.
“Operation not permitted” when setting a specific time
Write permission on a file is enough to update both its access and modification times to the current time. Changing only one timestamp with -a or -m, or setting a specific time with -d, -t, or -r, requires you to own the file or have appropriate privileges. Run the command as the file owner or with sudo. Ubuntu 25.10 and later ship the Rust rewrite of coreutils, and its touch reports the same error as Permission denied.
Access time does not change when reading a file
Most Linux distributions mount filesystems with the relatime option. With relatime, reading a file updates atime only if the previous atime is older than or equal to mtime or ctime, or more than 24 hours old. With noatime, reading a file never updates it. Neither option affects touch, and touch -a always sets the access time. Check the mount options with findmnt.
Cannot set ctime directly
The ctime (change time) cannot be set manually. The kernel updates it whenever 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. For other ways to create files, including files with content, see our guide on how to create a file in Linux
.
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 1000+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page