How to create empty file in Linux

How do I create an empty file from the bash shell or command line in Linux? Can you tell me command to create empty file in Linux?

Introduction – Empty file means files with zero bytes and in a plain text format — no data stored in a file. When you create a blank open office file, it contains extra data structure. The best way to create an empty file on Linux is to use the touch command.

How to create empty file in Linux using touch command

  1. Open a terminal window. Press CTRL+ALT+T on Linux to open the Terminal app.
  2. To create an empty file from command line in Linux:
    touch fileNameHere
  3. Verify that file has been created with the ls -l fileNameHere on Linux

Let us see some examples and commands to create empty file in Linux.

How to create an empty or blank file on Linux

As I said earlier use the touch command to create an empty file. In this example, the file “passbook.txt” created:
touch passbook.txt
See if file created or not with the help of ls command:
ls -l
ls -l passbook.txt

Use the cat command to verify that nothing stored in the file named passbook.txt:
cat passbook.txt

How to create an empty file using touch command on Linux

What is the purpose of the touch command on Linux?

The touch command used to update the access and modification times of given FILENAME to the current Linux time. If a FILENAME does not exist, it is created as an empty file. One can verify that file is empty with the following file command on Linux:
file passbook.txt
passbook.txt: empty

Creating empty file in Linux using > redirection operator

Another option to make empty file in Linux is just type the following command:
> file-name-here
echo '' > filename
ls filename
file filename


You learned that an empty file is a file that contains no data and got zero bytes in size. Further, you used the touch command to create an empty file on the Linux operating system.

Posted by: SXI ADMIN

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.


How to KVM, QEMU start or stop virtual machine from command line (CLI)

KVM or Kernel Based Virtual Machine is a popular virtualization technology. It allows you to run virtual guest machines over a host machine. To start...

How to Docker backup Saving and restoring your volumes

Running a Docker volume backup First, we spin up a temporary container, and we mount the backup folder and the target Docker volume to this container....

How to Start and Enable Firewalld on CentOS 7

In this article, we discuss how to start and enable firewalld. It is highly recommended that you have a firewall protecting your server.Pre-Flight CheckThese...