[Derry] random stuff

Seumas Mackinnon seumas at gmail.com
Fri Sep 28 15:16:00 UTC 2012


Hi all,

I've not been very good at keeping up with my reports. Here's some random
stuff to assuage my guilt...

Linux random devices. We talked about /dev/random and /dev/urandom. The
difference being simply that urandom doesn't wait for there to be enough
entropy in the pool before continuing, so it's pseudo-random. random OTOH,
does wait. Sounds pretty abstract but you can actually view it.

You can view the amount of entropy in the pool with:

cat /proc/sys/kernel/random/entropy_avail

The shuf command randomly picks something from a file, and you can specify
its random source, so if you do:

while true; do cat /proc/sys/kernel/random/entropy_avail; shuf -n 1
/usr/share/dict/words --random-source=/dev/urandom; done

You'll see it churn through the dictionary file and you'll see that the
number in entropy_avail never really drops. Compare with:

while true; do cat /proc/sys/kernel/random/entropy_avail; shuf -n 1
/usr/share/dict/words --random-source=/dev/random; done

(which is exactly the same except using "random" instead of "urandom").
Note the number drops and it stops when it runs out. If you want it to
continue, try wiggling your mouse about!

On the subject of randomness, we also had a brief mention of Bell's Theorem:

http://en.wikipedia.org/wiki/Bell%27s_theorem

Cheers, Seumas
-- 
Seumas Mackinnon
"It is in truth not for glory, nor riches, nor honours that we are fighting,
but for freedom -- for that alone, which no honest man gives up but with
life itself." -- Declaration of Arbroath, 1320
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/derry/attachments/20120928/51c9a116/attachment.html>


More information about the Derry mailing list