Quick take: The touch command creates empty files and updates file timestamps. touch file creates the file if it does not exist or refreshes its modification time if it does. Add -c to avoid creating new files.
Introduction
The touch command does two simple jobs: it creates empty files and it updates the access and modification timestamps of existing ones. It is one of the quickest ways to create a placeholder file, and its timestamp control is handy in build systems and scripts.
This guide covers creating single and multiple files, updating timestamps, setting specific times, and the options that change touch's default behaviour.
Syntax
The basic syntax of the touch command is:
touch [OPTIONS] FILE...Common Options and Parameters
The most useful options and parameters for the touch command:
| Option | Description |
|---|---|
| -c | Do not create the file if it does not already exist. |
| -a | Change only the access time. |
| -m | Change only the modification time. |
| -t STAMP | Use a specific time ([[CC]YY]MMDDhhmm[.ss]). |
| -d STRING | Use a human-readable date string ('2026-06-13 09:00'). |
| -r FILE | Use another file's timestamp as the reference. |
Practical Examples
Real touch commands you can run today:
# Create an empty file (or refresh its timestamp)
touch report.txt
# Create several files at once
touch file1.txt file2.txt file3.txt
# Update timestamp without creating a missing file
touch -c maybe.txt
# Set a specific modification time
touch -d '2026-01-01 12:00' newyear.log
# Match another file's timestamp
touch -r template.txt copy.txt
# Create many numbered files with brace expansion
touch test_{1..5}.txtTips and Best Practices
touchis the fastest way to create a placeholder file before you populate it later.- Refreshing a file's timestamp with touch can trigger build tools like
maketo treat it as changed. - Combine with brace expansion (
touch f{1..10}.txt) to create batches of files instantly.
Final Thoughts
touch is a tiny command with two clear uses: creating empty files and adjusting timestamps. Remember -c to avoid accidental file creation and -d/-t to set precise times, and it slots neatly into scripts and build pipelines alongside ls -l and stat.
FAQ: touch Command in Linux
How do I create an empty file in Linux?+
Run touch filename. If the file does not exist, touch creates it empty; if it does exist, touch updates its modification timestamp without changing the contents.
How do I create multiple files with touch?+
List them separated by spaces (touch a.txt b.txt c.txt) or use brace expansion (touch file{1..5}.txt) to create a numbered batch.
How do I update a file's timestamp without changing it?+
Just run touch filename — it refreshes the access and modification times to the current moment while leaving the contents untouched.
How do I stop touch from creating a new file?+
Use the -c flag: touch -c filename updates the timestamp only if the file already exists and does nothing if it is missing.
How do I set a specific date on a file?+
Use -d with a date string (touch -d '2026-01-01 12:00' file) or -t with a timestamp, or copy another file's time with -r reference file.
Need help with Linux servers or infrastructure?
Work directly with Muhammad Irfan Aslam for Linux, Ubuntu, Docker, DevOps, cloud, CI/CD, or infrastructure support.
Hire Me for Support