Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I deleted my /dev/null. How can I restore it?

share|improve this question
I once found that /dev/null was replaced with a normal file which only root could write to. I thought for a moment that I would have to reinstall everything but as mentioned below, the recovery is trival if you know the trick. – Stuart Woodward Dec 24 '11 at 12:15
I managed to remove /dev/null by getting my pipe wrong flipping $ and & around when running an rm command in a script. Ouch! – flickerfly Oct 9 '15 at 22:28
up vote 50 down vote accepted
mknod /dev/null c 1 3
chmod 666 /dev/null

Use these command to create /dev/null or use null(4) manpage for further help.

share|improve this answer
For completeness, I'd note that this applies to all linux-based systems; other systems may have different numbers. – Random832 Dec 21 '11 at 14:53
Also this only sets up the device file itself, it will not restore its permissions. You'll have to chmod go+w it manually. – Attila O. Jul 3 '15 at 9:44
The number of the beast! – ryvnf Nov 6 '15 at 16:21

Under many traditional unices, you can recreate devices with their default permissions with the MAKEDEV script. This script is traditionally in /dev but is in /sbin on Ubuntu. Pass it an argument that indicates what devices you want to create; on Ubuntu that's std (you can write MAKEDEV null as well, that creates null as well as a number of other devices).

Under modern Linux systems running udev, you can tell udev to recreate all or some devices based on available drivers and connected hardware, through udevadm trigger:

udevadm trigger --sysname-match=null
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.