How to create a 1GB random file in Linux

Posted on July 21, 2018 at 3:05 pm

You can use OpenSSL to create a 1 GB random file in Linux:

openssl rand -out sample.txt -base64 $(( 2**30 * 3/4 ))

1 Gigabyte is like 230 bytes (you can use 10**9 for 109 bytes instead).

The “* 3/4” section is for base64 overhead, making the encoded output exactly 1 GB.

Another (slower) way is to use dd like this:

dd if=/dev/urandom of=file.ext bs=1G count=1

Probably would be better to use bs=64M count=16:

dd if=/dev/urandom of=sample.txt bs=64M count=16

It means 64MB multiplied for 16 times = 1024MB = 1GB.

Receive updates via email

Other Posts

Updated Posts