Linux Create File

To create a file in Linux file system, you can use mkdir command with the Terminal, or > with file name next to it. And there are many ways in which you can create a file in Linux via Terminal.

In this tutorial, we shall learn how to create a file in two processes. In the first process, we shall use touch command. And in the second process, we shall use >.

Linux – Create File using touch command

Following is a step by step process to create a file in Linux using touch command.

Step 1: Open a Terminal. You may use the keyboard and type Ctrl+Alt+T, or open Applications, and search for Terminal.

And navigate to the directory in which you would like to create the file. In this example, we shall create a file named mynotes.txt in workspace directory.

Step 1 - Linux Create File

Step 2: Run the touch command, followed by file name.

$ touch mynotes.txt
Step 2 - Linux Create File

The file is successfully created.

Step 3: We can cross check if the file is created, by using ls command. Run the ls command, and you would see the file in the list, as shown below.

Step 3 - Linux Create File

Linux – Create File using “Redirecting Standard Output” Command

Following is a step by step process to create a new file in Linux via Terminal using >. This > command is also called Redirecting Standard Output.

Step 1: Open a terminal and navigate to the directory in which you would like to create a new file.

Step 1 - Linux Create File

Step 2: Run Redirecting Standard Output > command followed by file name.

Step 4 - Linux Create File

The new file is successfully created.

Step 3: To check if the file is created, run list command ls. The new file mygroceries.txt should be listed as shown in the following Terminal.

Step 5 - Linux Create File

Conclusion

Concluding this Linux Tutorial, we learned how to create a new file in Linux Terminal, with the help of commands.