Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Wait, you can actually remove /dev/null? I always thought of it as a special driver file

I guess that might not be true for all nixes out there



/dev/null is a device file, and can be removed by root, or any user with write access to the /dev directory itself.

You can recreate it with 'mknod /dev/null c 1 3; chmod 666 /dev/null'.

The '1 3' are the major and minor device numbers, respectively, which are assigned / maintained by LANA, the Linux Assigned Numbers Authority.


Each item in the unix filesystem can be one of the following: file, directory, symlink, device node, socket, fifo.

So nothing's stopping you from making it a normal file and capturing all the output programs send to it.

For super funsies you can make it a symlink or socket, but I think most programs won't work if it's a socket.

Nothing also is stopping you from removing it and mknod'ing a /dev/null into another device file, such as the one /dev/full or /dev/zero uses, or /dev/fb0 if you wanna be really silly.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: