| 7.3 Linux Math Tools | ||
| Learn advanced Linux commands | ||
|
head
-c 8 /dev/random Examples on how to generate random characters on the Linux command line by reading from the device "random" or "urandom". The first command produces approximately 8 characters by reading from the device "random", which generates high quality (difficult to predict) random numbers. It will become slow once the "entropy" on your computer is exhausted (e.g., when producing lots of random characters). The solution then is to wait or type something on the keyboard, move your mouse, switch the terminal, make your hard drive to read or write, etc., to generate more random noise ("entropy"). The second command keeps producing random characters, but displays them as octal numbers (using the "octal dump", od, filter). It has to be interrupted with <Ctrl><c>. The third command uses the device "urandom", which is faster then "random" when generating lots of random characters. But when the system enthropy is low, the randomness of its output from "urandom" might be compromised, yet it probably is still good for all but most demanding applications. The output is filtered to the mime format (the Internet mail-oriented 7-bit encoding standard) so it is all printable ASCII. The detailed description of the theorry and implementation of the Linux algorithm for generating the random numbers can be found in the source code file://usr/src/linux/drivers/char/random.c on your Linux system. Next > Back to "Learn Linux Commands"
|
||

