Thursday, October 22, 2020

How do I create a 1GB random file in Linux?

How do I create a 1GB random file in Linux?

🔥 Save unlimited web pages along with a full PDF snapshot of each page.
Unlock Premium →

if= is not required, you can pipe something into dd instead:

something... | dd of=sample.txt bs=1G count=1  

It wouldn't be useful here since openssl rand requires specifying the number of bytes anyway. So you don't actually need ddthis would work:

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

1 gigabyte is usually 230 bytes (though you can use 10**9 for 109 bytes instead). The * 3/4 part accounts for Base64 overhead, making the encoded output 1 GB.

Alternatively, you could use /dev/urandom, but it would be a little slower than OpenSSL:

dd if=/dev/urandom of=sample.txt bs=1G count=1  

Personally, I would use bs=64M count=16 or similar:

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

Source: https://superuser.com/questions/470949/how-do-i-create-a-1gb-random-file-in-linux/470957#470957
This web page was saved on Wednesday, Oct 21 2020.

Upgrade to Premium Plan

✔ Save unlimited bookmarks.

✔ Get a complete PDF copy of each web page

✔ Save PDFs, DOCX files, images and Excel sheets as email attachments.

✔ Get priority support and access to latest features.

Upgrade now →

2 comments: