•Arnošt Havelka
Creating Files with touch
Use touch to quickly create empty files.
Start Interactive LessonThe touch command creates empty files instantly. It's the fastest way to create a new file without opening an editor.
Create a Single File
Use touch followed by a filename to create an empty file.
Try the command
Create a new file!
Build the command
touch[arguments]
touch
Terminal
~$touch notes.txt
Create instantly:
Terminal
~$touch newfile.txt
ls
Create Multiple Files
Create several files at once by listing them after touch.
Try the command
Create multiple files!
Build the command
touch[arguments]
touch
file1 file2 file3Multiple files - creates all of them at once.
Terminal
~$touch a.txt b.txt c.txt
Batch creation:
Terminal
~$touch file1.txt file2.txt file3.txt
ls
Also Updates Timestamps
If the file already exists, touch updates its modification time without changing its contents.
Terminal
~$touch old.txt
ls -l old.txt
Knowledge Check
1 / 3What does touch do?
References
These documentation links provide authoritative details for the commands used in this article.
Up Next
Copying Files and Directories
Master cp to copy files and recursive directory structures.