How to create empty file in Linux

You can create an empty file in Linux using the touch command or by using a text editor.

Here’s the general process for creating an empty file in Linux:

  1. Using touch: You can create an empty file using the touch command and specify the name of the file as an argument:
touch [file-name]

For example, if you want to create an empty file named “emptyfile.txt”, you would run:

touch emptyfile.txt
  1. Using a text editor: You can also create an empty file using a text editor, such as nano or vi. To create an empty file using nano, run the following command:
nano [file-name]

For example:

nano emptyfile.txt

Once the editor opens, simply save the file without making any changes. This will create an empty file with the specified name.

Please note that the touch command will only create an empty file if a file with the same name does not already exist. If a file with the same name exists, touch will update the modification time of the file without changing its contents.

Leave a Comment