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 2: Run the touch command, followed by file name.
$ touch mynotes.txt
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.
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 2: Run Redirecting Standard Output >
command followed by file name.
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.
Conclusion
Concluding this Linux Tutorial, we learned how to create a new file in Linux Terminal, with the help of commands.