Create File of a Given Size using dd command

To create any file of given size in linux we can use dd command

Task is to create a file of size 10M

dd if=/dev/zero of=aa.txtt  bs=1024  count=10240
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.218581 seconds, 48.0 MB/s
$ ls -hl output.dat
-rw-r--r-- 1 raju raju 10M 2008-02-09 16:21 aa.txt

The above dd command creates a zero-filled file named aa.txt consisting of a count of 10240 blocks, each of block size 1024.
or you can use the below command which is more clear
$ dd if=/dev/zero of=aa.txt  bs=1M  count=10

Leave a Reply

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

*