How to create a file in linux terminal

Endrit Qerreti

Endrit Qerreti

Creating a file on Linux is easy, and you can do it just like on other linux distros. Touch command is the command that you can use to create a file from your terminal.

All files that are created with touch command, are empty files, so when you use touch command you can create a file without any content on it.

Even though the main function of touch command is to modify timestamps, touch command can also be used to create files.

In this tutorial, you will learn how to create a file in Linux terminal easily by using the touch command

Create an empty file using terminal in Linux

First, launch your terminal by pressing CTRL + SHIFT + T

Once terminal is launched, run the command below to create an empty file

touch myfile

The command above will create a file called myfile, system will create an empty text file even when you don't specify the file extension.

Create multiple files using terminal in Linux

To create multiple files from your terminal, you can do so by using the same command touch.

For example to create three text files, run the command below

touch file_1.txt file_2.txt file_3.txt

To verify that files were created , you can use the ls command


Create a file to a custom path

If you don't specify a path where to create a file, the file will be created on the same directory from where you launch terminal.

To create an empty file to a custom path, simply specify the path where you want to create the file

touch /path/to/create/the/file/file.txt

For example, to create a file on your Desktop, you can do so by running the command below

touch ~/Desktop/file.txt


In this tutorial, you learned that touch command can be used to create a single or multiple empty files in Linux terminal.