• Linux
  • FreeBSD
  • Networking
  • Python
  • AWS
  • WebDev
  • About Us

How to create an empty file of a specific size in Linux

Written by
Linux Leave a Comment

Sometimes , you might need to create files of different sizes for various testing purposes. For eg : testing an FTP or downloading a large file via VPN etc . The dd command in Linux is used to create the empty file with a specific size

dd if=/dev/zero of=testfile.dat  bs=1M  count=10

The above dd command creates a 10 MB ( 1M * 10 count) zero content file called ‘testfile.dat’ . If you want larger size , increase the count , ie count=15 creates a 15MB file .

WARNING : dd command can overwrite anything on your system , so you need to be cautious about the input and output files ie, if=the input file and of=output file and always double check it before running the command . dd –help will give you more info about this command .

© Copyright 2020.TechieNix. All Rights Reserved.