Ad space (banner)
🖥️Linux Lessons
Lesson 8 / 61

Creating a File with touch

touch is for when "I want to create one empty file." touch was originally a command for changing a file's modification timestamp, but pointing it at a filename that doesn't exist creates a new, empty file.

Use it in the form touch filename. Run it against a file that already exists, and only its modification timestamp updates to now, with the content untouched.

Running touch memo.txt creates an empty memo.txt in your current location. When you're ready to write content, follow up with an editor or echo.

A common early mistake is assuming touch is "a command for creating file contents." In reality, it only creates an empty file, or updates the modification timestamp.

In real work, this is used for build marker files (like lock files), or preparing an empty file for a test.

Linux
Try it (type this into the pseudo terminal)
touch memo.txt

🧑‍💻 You can type this command into the Linux pseudo terminal to try it yourself (this page itself has no interactive terminal).

Ad space (banner)
Ad space (in-article)