Menu
Coddy logo textTech

Create A File

Part of the Fundamentals section of Coddy's Terminal journey — lesson 10 of 82.

The touch command is used to create a new empty file in your current directory.

Simply type touch followed by the name of the file you want to create:

touch hello.txt

This creates a new empty file called hello.txt. You can confirm it was created by running ls:

ls
hello.txt

Creating multiple files at once:

You can create several files in a single command by listing them separated by spaces:

touch file1.txt file2.txt file3.txt

Creating a file inside a folder:

You can create a file directly inside another directory without navigating into it first:

touch documents/notes.txt

Note: If the file already exists, touch will not overwrite it — it simply updates the file's last modified timestamp.

challenge icon

Challenge

Beginner

Create a new file called hello.txt in your current directory, then use ls to confirm it was created.

Hint: Use the touch command followed by the filename.

Cheat sheet

The touch command creates a new empty file:

touch hello.txt

Create multiple files at once by separating filenames with spaces:

touch file1.txt file2.txt file3.txt

Create a file inside a specific directory:

touch documents/notes.txt

Note: If the file already exists, touch updates its last modified timestamp without overwriting it.

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals