cat /dev/urandom
To generate and write random data to a file, use the following command:
cat /dev/urandom > randfile
To limit the output, Ctrl+C the process, or use a sleep followed by kill. For example:
(cat /dev/urandom > randfile &); sleep 5; killall cat
The command sequence above will write random data to randfile for five seconds. The actual amount of data written will vary.