Home Linux Commandline Tools How to Create a Large 1GB or 10GB File in Linux

How to Create a Large 1GB or 10GB File in Linux

Before we dive into the procedural steps needed to create large files in a Linux operating system environment, we must answer the WHY before we dwell on the HOW.

WHY create large files on a Linux operating system environment? Afterward, HOW do you create large files on a Linux operating system environment?

Why Create Large File on Linux

In Linux, you will find the need for dummy or sample files very useful in various operating system scenarios. You might need these files for testing or debugging OS-related functionalities or even projects.

For you to perfectly test or debug anything under Linux, you will need your dummy or sample files to exist in various sizes. Therefore, instead of wasting time populating a file with data to achieve the desired file size, you can achieve this objective with the mastery of a few Linux commands.

How to Create a Large File on Linux

Before we dwell on the HOW, consider this scenario: You have created or you have come across a promising Linux archive utility project/application. To test its performance and efficiency, you need instant access to a 1GB or 10GB file. It is under such circumstances that we reference system text manipulating commands to create our files.

We are going to primarily reference the dd command to demonstrate the creation of our large files. Additionally, you might need the assistance of the following listed commands.

Using dd Command to Create 1GB or 10GB Files

The syntax for this command is highlighted below:

$ dd if=/dev/zero of=/path/to/file/storage/output.img [options]

Alternatively, the following detailed syntax reference also works.

$ dd if=/dev/zero of=YOUR_IMAGE_FILE_NAME bs=1 count=0 seek=File_Size_HERE

To make this article guide interesting, we are going to create a 10GB file on our Linux system. The command we are going to use is as simple as demonstrated below. Make sure your Linux system can accommodate the file size you want to create through the following df command.

$ df -H
Check Linux Disk Space Usage
Check Linux Disk Space Usage

On my end, I have 14GB of free disk space. It will be sufficient to accommodate the 10GB file we want to create.

To create the 10GB file on my Linux machine, I will run the following command.

$ dd if=/dev/zero of=10g.img bs=1 count=0 seek=10G
Create Large Dummy File in Linux
Create Large Dummy File in Linux

The next step is to verify that our created image file actually exists.

Verify Large Dummy File in Linux
Verify Large Dummy File in Linux

As highlighted on the above screen capture, the 10g.img image file does exist. The next step is to verify the size of this image file.

$ stat 10g.img
Check File Size in Linux
Check File Size in Linux

The size of our created file is indeed 10GB as per the above screen capture.

You can also right-click on this image file and accessing its properties will also highlight the expected size property.

Check File Properties in Linux
Check File Properties in Linux

The below du command implies that despite the existence of the created 10GB file size, the Linux operating system recognizes the disk usage of this 10GB file as zero since it’s a dummy binary image file (non-text file) and is yet to hold any sizable data.

$ du -h 10g.img
Dummy Binary Image File
Dummy Binary Image File

You might also like to read the following related articles:

For whatever reason, you might need to create a dummy or test file under your Linux operating system environment, always consider the speed and efficiency of Linux’s inbuilt dd command to get things done. If you need to explore more options relating to the usage of this command, run man dd on your Linux terminal.

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.