Skip to content

/dev/urandom | Cheatsheet


Create Several Files Filled with Random Data

for fileSize in 1 10 50 100 250 500 1000; do 
    echo "Creating file: ${fileSize}M"; 
    sudo head -c ${fileSize}M </dev/urandom >${fileSize}; 
done

Create a File with Random Data Using 'head' Command

head -c 50M </dev/urandom >50MB
Create a File with Random Data Using OpenSSL
openssl rand -out sample.txt -base64 $(( 2**30 * 3/4 ))
openssl rand -base64 1000 | dd of=sample.txt bs=1G count=1

Create a File with Random Data Using 'head' Command

head -c 1073741824 </dev/urandom >myfile

Create a File with Random Data Using 'fallocate'

fallocate -l 100KB dummy_100KB_file

Generate a File with Random Alphanumeric Characters

< /dev/urandom tr -dc "\t\n [:alnum:]" | head -c1000 > file.txt