The Linux touch Command: Create or Update Timestamps

The Linux touch Command: Create or Update Timestamps

touch creates empty files or updates timestamps on existing files.


Basic Usage

Create file

touch newfile.txt

Creates empty file.

Update timestamp

touch existing.txt

Updates mtime to now.


Options

  • -a — Change atime only
  • -m — Change mtime only
  • -c — Don't create (just update)
  • -d TIME — Set time
  • -r FILE — Use timestamp from reference file

Examples

Don't create

touch -c nonexistent.txt

Does nothing (no error either).

Use reference time

touch -r otherfile.txt newfile.txt

Copies timestamp from otherfile.

Set specific time

touch -d "2024-01-01 00:00" file.txt

Set exact timestamp.


Further Reading