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
Following is a step by step process to create a file in Linux using touch command.
- 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.
- Run the touch command, followed by file name. The file is successfully created.touch mynotes.txt
- 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.
Following is a step by step process to create a new file in Linux via Terminal using
> command is also called Redirecting Standard Output.
- Open a terminal and navigate to the directory in which you would like to create a new file.
- Run Redirecting Standard Output
>command followed by file name. The new file is successfully created.
- 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.
Concluding this Linux Tutorial, we learned how to create a new file in Linux Terminal, with the help of commands.