954,483 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

/dev/random

Hello Everybody,

I am on a Ubuntu system and I just came across /dev/random

I tried searching for examples of how to use this utility (or file/ or command) to generate a random number but I cannot find anything.

Quick note I am trying to generate a random number on the command prompt not in a C program. Is this possible ?

abhimanipal
Master Poster
742 posts since Dec 2009
Reputation Points: 114
Solved Threads: 104
 

If you're just trying to display the result, something like this would work:

$ cat /dev/random | od -tl -w4

Remember that /dev/random is just a file. You can process it like any other file.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

I ran the command as you said and I am getting an error

~$ cat /dev/random | od -tl -w4
od: invalid character `l' in type string `l'
^C
~$ ^C

abhimanipal
Master Poster
742 posts since Dec 2009
Reputation Points: 114
Solved Threads: 104
 

Run man od for a list of supported formats on your system.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You