[ELI5] /dev/null, /dev/random, /dev/urandom and /dev/zero

847 views

I’ve been reading about this files and also I have tried to inspect by myself about this files (file, ll, Stat and some other commands) but I just don’t understand them.

Can someone please explain me what are these files and how can I used them?

In: Technology

8 Answers

Anonymous 0 Comments

/dev/null is end of file when read and discards data when written. It’s convenient to redirect input for programs that otherwise expect a keyboard, and discard unwanted output like directory errors from “grep <something * 2>/dev/null”.

/dev/random and /dev/urandom are the same driver, which collects entropy (randomness) from activity on the system. /dev/random will delay until it has collected enough random bits for the request, /dev/urandom will “make up” random numbers (using a random number generator) if necessary, so it won’t block. /random provides stronger numbers for things like cryptography, the /urandom is good enough for games and similar programs.

/dev/zero discards written data, and returns just zeros. I’ve used it to rapidly (and only mildly securely) overwrite files, and a source of data to create files of fixed size.

You are viewing 1 out of 8 answers, click here to view all answers.