Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What is the mechanism by which rm /dev/null is prevented? Specifically on FreeBSD, but I'm just as interested in all other Unix based systems.

share|improve this question

migrated from stackoverflow.com Apr 26 '11 at 1:59

This question came from our site for professional and enthusiast programmers.

    
Common logic, you can't remove nothing ;) –  mazzzzz Apr 26 '11 at 1:42
5  
Have you tried ? –  dtmilano Apr 26 '11 at 1:43
add comment

2 Answers

up vote 12 down vote accepted

You can actually delete /dev/null as user root on Linux and BSD systems. Of course once system is rebooted /dev/null will be restored. Without rebooting also it is possible to restore /dev/nullusing mknod command.

share|improve this answer
add comment

Permissions - unless you are running as root (super-user) or possibly one of a select few other users or groups (bin or sys), you do not have write permission in the /dev/ directory, and therefore cannot remove anything from the directory.

If you are root, then you could remove it - but your system would be extremely unhappy. You could recreate it, using the mknod command (or perhaps the mknod() system call). Or you could create a plain file, but that would not have the same special properties as the 'real' /dev/null and would leave your system severely crippled.

It is not a good area for experimentation! (And, if you must experiment, I recommend using a VM rather than your main machine.)

share|improve this answer
add comment

Your Answer

 
discard

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.