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.

Is there a way to replace /dev/null device with a regular file (or a device that appends to a file, perhaps)? How much data is written to it?

(This slightly odd question is partially inspired by this..)

share|improve this question
4  
Sorry if this sounds stupid and someone else understands, but I don't understand why it has the green-computing tag? –  William Hilsum Oct 27 '09 at 2:05
1  
It's in the linked article, solution #2. Kind of subtle, too. –  gbarry Oct 27 '09 at 3:00
5  
Why not just unplug your network from the wall and cat /dev/null > eth0 with the loose end of the cable in a waste bucket. Then you can easily weigh all the bits that fill it up on any ordinary household scale ;-) –  DaveParillo Oct 27 '09 at 4:34
    
@Wil: It was a joke more than anything, see c2.com/cgi/wiki?DevNull that was linked at the end of the question.. –  dbr Oct 27 '09 at 17:50

3 Answers 3

up vote 9 down vote accepted

I would strongly advise against doing so ... depending on your system the resulting file could grow really fast. However, it's quite easy to have fun with a VM.

I will describe how to do this during one session, i.e. everything should be back the way they were after a reboot.

Obviously, this has to be done as root.

First, you need to delete the current /dev/null:

rm /dev/null

Then create a replacement file with the same name and some adequate permissions:

touch /dev/null
chmod 666 /dev/null

You may now visualize what is sent to /dev/null:

tail -f /dev/null

Finally to bring back /dev/null to its normal behaviour:

rm /dev/null
mknod /dev/null c 1 3
chmod 666 /dev/null
share|improve this answer

You can delete /dev/null and touch it as root, then restore it's permissions.

The special device goes away and you get a file instead.

enjoy.

share|improve this answer

On OpenBSD:

cd /dev
sudo mv null blah
sudo touch null
sudo chmod a+rwx null
echo foo > /dev/null

Some linuxes AFAIK have special device filesystems - devfs; udev - that may complicate this simple procedure.

share|improve this answer

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.