How to Create a New File in Linux 


               


How to Create a New File in Linux



Linux


In this article, we show how to create a new file in linux.

So linux is perfectly capable of creating new files within the linux command terminal.

For example, if you want to create a text file (.txt), then we can do this through the linux command terminal. We do not have to go to the notepad software and open up and create the file. We can do this with linux.

We create a new file in linux through the touch command.

After the touch command, we specify the name of the file.

Linux will then create the file in the current working directory that you are in. To know the current working directory you are in, then you just have to use the statement, pwd

This is the directory where the new file will be created with the touch command in linux.

So below I create a text file called data1.txt



Running the following code above, we get the following output shown below.


Creating a new file in linux


So we've printed out the current working directory with the statement, pwd

You can see that the current working directory, when I ran this code, was david/home/

So this is where the new file will be created.

I use the touch command in linux to create the text file, data1.txt

When I then go to this directory, I see this new document, data1.txt

Initially, it is a blank file when created.

And this is hwo to create a new file in linux.


Related Resources

How to Randomly Select From or Shuffle a List in Python



HTML Comment Box is loading comments...