Linux - touch command in Linux

The touch command in Linux is used to create empty files or update the timestamp of existing files. It’s simple but powerful—especially when scripting or managing files.


 What Does touch Do?

Basic Usage

touch filename
  • If filename doesn’t exist, it creates a new empty file.
  • If it does exist, it updates the file’s access and modification times to the current time.

 Common Options

Option Description
touch file1 file2 Creates multiple files at once
touch -c filename Doesn’t create the file if it doesn’t exist
touch -t [[CC]YY]MMDDhhmm[.ss] filename Sets a custom timestamp
touch -a filename Updates only the access time
touch -m filename Updates only the modification time
touch -r reference.txt filename Sets the timestamp of filename to match reference.txt

Example Commands

touch notes.txt

Creates an empty file called notes.txt.

touch -c oldfile.txt

Updates timestamp only if oldfile.txt exists.

touch -t 202508151030.00 report.txt

Sets the timestamp of report.txt to August 15, 2025, 10:30 AM.


 Check the Result

Use ls -l to verify the timestamp:

ls -l report.txt

Pro Tip

In scripting, touch is often used to:

  • Create marker files
  • Trigger processes based on file existence
  • Reset timestamps for build tools like make