How ToSoftware

Steps to create a file in Linux Terminal

Are you a windows users or having laptop user, then it will be very easy for you to create a file. But in linux everything will be different that all the functions should be accessed only through command line. Now we going to tell you steps to create a file in Linux Terminal

How to create file in linux

We going to tell you steps to create file in linux terminal by seven different methods which are

  • By using touch command
  • Using redirection operator
  • Use cat command
  • Using text editors
  • By using fallocate
  • Using printf command
  • Use echo command

Guys for example we have used techfranks to make you understand. You can use your file name. All the following commands run in terminal window open it by pressing ctrl+ alt+ F2 or ctrl + alt + T

Creating file with touch command

  • At first you have to create a new empty file in linux machines. By using touch command why because it will be easy and now open the terminal and the run the below following command

Touch techfranks.txt

  • Now a new file were created in the name techfranks.txt. you can preview it by entering


  • To create a word file and run

Touch techfranks.docx

  • If you want to create multiple files then you have to enter the file names with space between them

Touch techfranks.docx techfranks1.docx techfranks2.docx

Creating a file with redirection operator

This method will be simple for you create a file. Here you have to use redirection operator which was followed by file name. It will redirect the output of command to your new file


  • Create a docx file


  • Finally done

Creating a file with cat command

This cat command is read the files also by using this command you can able to create file on linux

  • To create empty file named techfranks, run as

cat > techfranks.txt

Now click on enter and then type text which you want and click on ctrl + D it will save your file

Creating a file with echo command

This echo command is used to print the text which you have typed in command and put them all in your file

  • To create an empty file 

echo > techfranks.txt

  • Creating a file with text

echo “some text” > techfranks.txt

create a file with printf command

by using this printf command you can able to add two lines of text into file

Creating file with single text

printf ‘first line of text\n’ techfranks.txt

  • Creating file with two lines of text

printf ‘first line of text\n second line of text’ techfranks.txt

creating a large file on linux using fallocate command

This fallocate is used to create a large files in your linux. Creating a file in size 1 GB

fallocate – 1 1G tcehfranks. file extension

creating files on linux using text editors

We bring you some of the  text editors like vi, nano and vim you can use it instead of using command

Vi editor

You can use this editor to create and edit files for that enter enter

vi techowns.txt

now this editor will open you have to click the letter “I” and type some words then to save and quit you have to type ESC: X and click on enter

Nano editor

Creating a file using nano editor enter the following command

nano techfranks.txt

On nano editor you have to type some word and to save press ctrl + o and to exit press ctrl + X

vim editor

Creating a file using vim editor enter the below command

vim techfranks.txt

Now you have to click on the “ I “ letter which is insert mode. And then type Esc:wq and click on enter save and exit file 

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button