/dev/random
and /dev/urandom
are not ordinary files ... they are character special devices. In Linux, block special devices and character special devices are filesystem interfaces to an operating system device driver. If you run the command ls -l /dev
you will see listings that have either a "b" [for block] or a "c" [for character] in the first column. By convention, these are placed in the /dev directory tree, but a special device can be created anywhere on the filesystem.
Block and character special devices are not created by copying or moving ... they are created using the mknod
command.
Normally, /dev/random
and /dev/urandom
are created when the operating system is booted. The devices are created dynamically when the random number generator is running. If you reboot your Linux system and they are not being created automatically, then you need to check to see whether something was changed in the kernel configuration to disable it.
If the files are disappearing or get deleted by accident, they can be recreated as follows (as root):
/bin/mknod -m 0666 /dev/random c 1 8
/bin/mknod -m 0666 /dev/urandom c 1 9
/bin/chown root:root /dev/random /dev/urandom