←back to thread

587 points swills | 3 comments | | HN request time: 0.201s | source
Show context
pyuser583 ◴[] No.45688089[source]
I've used /dev/null for exactly this purpose. I have output that needs to go somewhere, and I don't want to worry about whether that somewhere can handle it.

Later on in deployment, it will go somewhere else. Somewhere that has been evaluated for being able to handle it.

In that way, /dev/null is to storage what `true` is to execution - it just works.

replies(1): >>45688260 #
CaptainOfCoit ◴[] No.45688260[source]
Bug free software is a pipe dream, but if there is anything I've never encountered any bugs with, /dev/null and true is certainly in the top 3.
replies(4): >>45688480 #>>45688959 #>>45690296 #>>45692706 #
tuetuopay ◴[] No.45692706[source]
The only bug with it was due to my own stupidity. I wanted a quick way to see how fast a drive was, thus sending one of its large files to /dev/null was fine. Except I went too fast and cp'd the file to /dev/null.

It took a while before noticing I had no more /dev/null on the machine (read: the time needed to fill the rootfs). In a panic, I removed the file.

Seeing the machine collapse due to /dev/null missing was fun.

replies(1): >>45695484 #
1. augusto-moura ◴[] No.45695484[source]
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

replies(2): >>45696381 #>>45699507 #
2. dredmorbius ◴[] No.45696381[source]
/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.

3. RiverCrochet ◴[] No.45699507[source]
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.