The touch
command is one of the quickest ways to create new empty files or update timestamps for existing files in Linux. It’s widely used by system administrators, developers, and anyone who works with scripts or manages lots of files. Mastering touch
can boost efficiency, automate file creation, and help maintain proper timestamp records.
touch [options] filename
Replace filename
with your desired file or directory name. Include multiple names to create several files at once.
touch resume.txt
This command makes an empty file named resume.txt
in the current folder.
touch chapter1.md chapter2.md chapter3.md
Boom! Three files land in your directory, ready for editing.
touch backup_{A,B,C}.tar.gz
Creates backup_A.tar.gz
, backup_B.tar.gz
, and backup_C.tar.gz
at the same time.
touch -c report.txt
Only updates timestamps if report.txt
exists; doesn’t create it if it doesn’t.
touch -a visitors.log # Only access time
touch -m summary.docx # Only modification time
touch -r old_version.txt new_version.txt
new_version.txt
now has the same timestamps as old_version.txt
.
touch -t 202510011200.00 archive.log
Set timestamps to October 1, 2025, 12:00:00.
Option | Description |
---|---|
-a | Change access time only |
-m | Change modification time only |
-c | Don’t create files if they don’t exist |
-r | Set times based on another file’s timestamps |
-t | Set a specific date/time (format: [[CC]YY]MMDDhhmm[.ss]) |
Read More: History of Linux
While file extensions in Linux are optional and often misleading, the file command helps decode what a…
Handling large numbers of files is routine for Linux users, and that’s where the find command shines.…
Managing files and directories is foundational for Linux workflows, and the mv (“move”) command makes it easy…
Creating directories is one of the earliest skills you'll use on a Linux system. The mkdir (make…
Lyric videos have become one of the most popular tools for artists to share music…
The cp command, short for "copy," is the main Linux utility for duplicating files and directories. Whether…