Take the 2-minute tour ×

How can I use /dev/(u)random on Ubuntu or any *nix sistems ?
I searched at google but I can't find how to :(
I tried this but it says permission denied.
Note : I also tried as root.

sudo /dev/(u)random
sudo -s;/dev/(u)random
share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

It's a file like device, so you can do things like cat it or copy from it. For instance:

dd if=/dev/urandom of=~/urandom_test count=4 bs=1024

Creates a file containing 4K of random bytes.

cat /dev/urandom > ~/urandom_test2 

Will continue to write random bytes to that file until you hit Ctrl-C. Don't do this on a low performing system...

head -30 /dev/urandom > ~/urandom_test3

Will write 30 lines of random bytes

share|improve this answer
Thanks, worked :) –  Caner Korkmaz Sep 23 '12 at 19:33
Feel free to upvote then! –  aychedee Sep 23 '12 at 19:36
I would if my rep > 15 –  Caner Korkmaz Sep 23 '12 at 19:38
Note : Don't do cat /dev/urandom > ~/urandom_test2 on low-performance systems -> that freezes the system –  Caner Korkmaz Sep 23 '12 at 19:44
Ah, true. I'll change my second example. –  aychedee Sep 23 '12 at 19:50
add comment

Your Answer


