How to Create Files and Update Timestamps with touch

Published 2026-08-05 · Learn Linux

The touch command creates empty files and updates file timestamps. touch notes.txt creates the file if it does not exist, and updates its modification time if it does. It is a small command with two handy jobs.

Create an empty file

The simplest use: create a file that does not exist yet. If it exists, touch just refreshes its timestamp. Create several at once by naming them all.

$ touch notes.txt
$ touch index.html style.css app.js

Placeholder files

Empty files are useful as placeholders. A .gitkeep makes Git track an otherwise empty folder, and lock files signal that a process is running.

$ touch .gitkeep

Set a specific time with -t

Use -t with a timestamp in the form YYYYMMDDhhmm to set the modification time exactly:

$ touch -t 202607011200 report.txt

Set the timestamp to now

To refresh a file's modification time to the current moment, just run touch on it with no options. This is how you mark a file as recently changed for build systems that watch timestamps.

$ touch config.conf

Create files in a new folder

touch fails if the parent folder is missing. Create it first with mkdir -p. See touch for the full reference.

Keep learning

Related guides: How to Create and Remove Directories with mkdir and rmdir · The Linux ls Command: List Files Like a Pro · How to Copy Files and Directories with the Linux cp Command. Read all tutorials on the Learn Linux blog.