Creating an Empty File in Linux | Touch Command (original) (raw)

Last Updated : 8 Dec, 2025

The touch command in Linux is used to create an empty file or update the access and modification timestamps of existing files. It’s one of the simplest and most commonly used commands for file management.

**Examples

Below are the examples of creating files using the touch command:

1. Create a Single Empty File:

You can create a single file at a time using touch command.

touch GeeksforGeeks.txt

file

2. Create Multiple Empty Files:

Creates three empty files simultaneously.

**Command:

touch gfg1.txt gfg2.txt gfg3.txt

file

Syntax

touch [options] [file_name...]

Commonly Used Options

Here is the commonly used options in the touch command

1. -a: Change Access Time Only

**Example:

touch -a file.txt

**How to Verify:

stat file.txt

file

**You’ll notice:

2. -m: Change Modification Time Only

**Example:

touch -m file.txt

**How to Verify:

stat file.txt

file

**You’ll see:

3. -c or --no-create: Do Not Create New File

**Example:

touch -c oldfile.txt

**How to Verify:

**Check using:

ls -l oldfile.txt

file

You’ll either see the updated timestamp (if file existed) or an error (if not found).

4. -r: Use Reference File’s Timestamp

**Example:

touch-r reference.txt target.txt

**How to Verify:

stat reference.txt stat target.txt

file

**You’ll see:

5. -t: Set a Custom Timestamp

**Purpose: Manually set a specific date and time for a file’s access and modification times.

**Format:

[[CC]YY]MMDDhhmm[.ss]

**Example:

touch -t 202510231230.30 file.txt

**How to Verify:

stat file.txt

file

**You’ll see:

Practical Use Case

The touch command is often used in automation scripts to: