96

I understand that reads to /dev/random may block, while reading /dev/urandom is guaranteed not to block.

Where does the letter u come into this? What does it signify?

Userspace? Unblocking? Micro?

Update:

Based on the initial wording of the question, there has been some debate over the usefulness of /dev/random vs /dev/urandom. The link Myths about /dev/urandom has been posted three times below, and is summarised in this answer to the question When to use /dev/random vs /dev/urandom.

Tom Hale
  • 30,455
  • 15
    Unblocking, as opposed to /dev/random which is blocking. – Satō Katsura Nov 16 '16 at 05:49
  • 3
    Chapter and verse? – Tom Hale Nov 16 '16 at 05:53
  • 12
    The idea that /dev/random was somehow better than /dev/urandom is now long obsolete and for the vast majority of use cases, /dev/urandom is now preferred. – David Schwartz Nov 16 '16 at 12:26
  • @SatoKatsura Source? Tom's answer contradicts your answer. – noɥʇʎԀʎzɐɹƆ Nov 17 '16 at 00:17
  • Here is a link to site with details to backup @DavidSchwartz 's comment. http://www.2uo.de/myths-about-urandom/ – Walter Nov 17 '16 at 01:33
  • @Walter The "is now preferred" part in David's comment is a link to that page. :) – muru Nov 17 '16 at 01:44
  • @uoɥʇʎPʎzɐɹC That's ok, I can stand other people disagreeing with me. :) IIRC /dev/urandom did exist on commercial systems before Linux, and the main difference from /dev/random was blocking behavior, but I don't have a reference to point you to. If you believe a comment in a patch from 1995 is the proper explanation, go with that. Maybe it is the proper explanation for Linux. You guys could also just ask T. Ts'o (the author of the patch). – Satō Katsura Nov 17 '16 at 05:35
  • @SatoKatsura Hitchen's razor: can you provide some evidence for you assertion rather than asking us to contact someone extremely in-demand to disprove it? Note, I did try to find this evidence myself (see comments in my answer). – Tom Hale Nov 17 '16 at 11:43
  • From my comment above: "I don't have a reference to point you to" (which is why I didn't post it as an answer). As for Hitchen's razor, whatever that might be: I wasn't asking you to do anything to prove or disprove my claim. I was just pointing out there is a way to get a definitive answer to your question, rather than speculate on [unix.se]. Not sure why you're assuming contacting Theodore Ts'o would be such a huge endeavor. Still, please do ignore me on both counts if that makes you feel better. – Satō Katsura Nov 17 '16 at 12:02
  • @SatoKatsura "Not sure why you're assuming contacting Theodore Ts'o would be such a huge endeavor" agreed, especially since he's a user on this site already! – Stephen Kitt Nov 17 '16 at 12:08
  • @SatoKatsura Hitchen's razor is explained in Wikipedia link I gave, but in summary: the burden of proof regarding the truthfulness of a claim lies with the one who makes the claim; if this burden is not met, the claim is unfounded and its opponents need not argue further in order to dismiss it. I admit you may be right though! :) Also note that I didn't say that it would be a "huge endevour" - my intent was to say that he is likely a busy guy and currently the burden of proof lies upon you. – Tom Hale Nov 17 '16 at 12:15
  • Surely it would have been /dev/nrandom for "non-blocking" rather than unblocking. – Mr Moose Nov 18 '16 at 03:38
  • @MrMoose I posted a comment earlier with a few alternative interpretations. Some moderator wisely decided to delete my comment, but I'll (shamelessly) recall two of them here: useless, because people in the know claim /dev/urandom is weaker than /dev/random; and useful, because other people in the know claim we should still use /dev/urandom. Also, a few other things (f.i. umount and fsck) were not initially intended to be named that way. So pick carefully. :) – Satō Katsura Nov 18 '16 at 05:08

3 Answers3

99

Unlimited.

In Linux, comparing the kernel functions named random_read and random_read_unlimited indicates that the etymology of the letter u in urandom isunlimited.

This is confirmed by line 114:

The /dev/urandom device does not have this limit [...]

Update:

Regarding which came first for Linux, /dev/random or /dev/urandom, @Stéphane Chazelas gave the post with the original patch and @StephenKitt showed they were both introduced simultaneously.

Tom Hale
  • 30,455
  • 8
    Then why isn't /dev/random named /dev/lrandom? :) – Satō Katsura Nov 16 '16 at 06:13
  • 14
    Historical. At first only the limited / blocking version existed. And the analogous "non-un-limited" function is called random_read :) – Tom Hale Nov 16 '16 at 06:25
  • Wikipedia says unlimited, also citing random_read_unlimited function (in fact, even the same commit). If you got this from Wikipedia, please say so. – muru Nov 16 '16 at 11:53
  • 10
    I did find one of the links via Wikipedia, but I'm quoting the source directly rather than quoting Wikipedia. I'd consider it analogous to finding something via google, and not quoting google... unless I have something to learn about quoting on StackExchange? – Tom Hale Nov 16 '16 at 13:04
  • 5
    @TomHale The historical argument for random v. lrandom doesn't hold all that well since both random and urandom were introduced simultaneously in the Linux kernel. – Stephen Kitt Nov 16 '16 at 13:23
  • 2
    @TomHale 2007 is the date at which the 1.3.30 kernel was imported into the historical git repository you're referring to, not the date at which the patch was applied to the kernel originally. 1.3.30 was released in 1995, so it predates Solaris 7. (git didn't exist back then.) – Stephen Kitt Nov 16 '16 at 14:31
  • 1
    @StephenKitt Thanks for the correction. I deleted the comment you were referring to by accident, but here is the Solaris link I originally posted. – Tom Hale Nov 16 '16 at 14:35
  • 7
    See also the patch on usenet sent by the author of the original implementation back in 1995 – Stéphane Chazelas Nov 16 '16 at 14:38
  • @TomHale It's not analogous because some person did the work for finding that reference and adding it to Wikipedia. Not acknowledging that doesn't seem right. I'm sorry, but I'm downvoting this. – muru Nov 17 '16 at 01:43
  • 1
    @TomHale instead of telling people to disregard upvotes on your comment, you could delete the comment... – Stephen Kitt Nov 17 '16 at 08:47
  • @StephenKitt, agree, referring to the upvotes wasn't helpful (edited). I'm leaving the comment as-is as I don't want to create another discontinuity and there's some because of the info re random_read. – Tom Hale Nov 17 '16 at 11:33
21

It depends on which "Unix" system you are talking about.

On FreeBSD, /dev/urandom and /dev/random are the same device. The letter u is now a historical legacy that exists for backward compatibility. At startup, they block until enough entropy has been gather and then never block again. See Myths about urandom for details.

In the modern Linux world (starting with kernel 4.8), both devices pull from the same CSPRNG, so the only difference is that some people speculate at the existence of an attack. This attack is like FTL [Faster than Light] travel. Easy to speculate about, rather hard to actually design.

TLDR is just use /dev/urandom.

Walter
  • 389
  • 2
    From your link, it's interesting to note that FreeBSD does the right thing: they don't have the distinction between /dev/random and /dev/urandom, both are the same device. At startup /dev/random blocks once until enough starting entropy has been gathered. Then it won't block ever again. – Tom Hale Nov 17 '16 at 04:55
-6

Uniform. Random numbers uniformly distributed between 0 and 1. A flat distribution... as opposed to a peaked distribution like Poisson, or Normal/Gaussian.

bbneo
  • 9
  • 3
    Have any source for that one? – GnP Nov 17 '16 at 18:18
  • 7
    This is definitely not right- /dev/random and /dev/urandom both give the same distribution, and in any real sense it's not uniformly distributed between 0 and 1. – Chris Nov 17 '16 at 19:35
  • Sorry... probably based that on another language I have used (R or something) – bbneo Dec 05 '16 at 20:11