I find it odd that only one writeup shows an actual use for /dev/null.

Okay, so here's one. Let's say a configure script wants to probe for pthread support:

echo "#include <pthread.h>\n\nint main() { return pthread_create( NULL, NULL, NULL, NULL ); }\n" > test.c
cc test.c ${LIBS} -o test 2>/dev/null

The script makes a simple pthread program and compiles it, redirecting its error stream to /dev/null. That way the user does not see compile errors. The script then checks the return code of the C compiler. If it's zero, it compiled and there is pthread support. Otherwise, there was a compile error thus there is no support for POSIX threads, and the script can give a verbose error message.

Well, that's one usage for /dev/null.

= 0 = 0

/dev/null /dev-nuhl/ n.

[from the Unix null device, used as a data sink] A notional `black hole' in any information space being discussed, used, or referred to. A controversial posting, for example, might end "Kudos to rasputin@kremlin.org, flames to /dev/null". See bit bucket.

--The Jargon File version 4.3.1, ed. ESR, autonoded by rescdsk.

A relativly low level, harmless troll I once tried is to ask various linux centered usenet groups about the null device, pretending as if I believed it was a real, physical device.

For example, I asked whether or not I could install Linux on my new computer, because I was using all my serial ports, and didn't know if I could find any USB drivers for a /dev/null

There could be quite a few variations on this theme, as in asking Linux newsgroups whether or not they have /dev/nulls for The Cube, or whether you can get one small enough to attach to your new, ultra small laptop. The possibilities are endless.

This could be a funny prank, if the pranker manages to keep it within acceptable levels of obnoxiousness.

In Unix, everything is a file, including physical and logical devices, like disk drives, terminals, printers, tape drives, and in a strange way, even memory.

/dev/null is a character device with no physical manifestation. It is humorously called the write only backup device by the bofh community. On the surface, this may seem useless -- why bother writing to a device when you can never read the data back? The reason for writing to it is exactly that -- you never want the data back.

The /dev/null pseudo device is used specifically to throw away data you don't want. It is used by either redirecting output to the device, or by mentioning the device where the application expects an output filename. Sometimes it is easier to just tell the app to write its log file to /dev/null than to provide an option in the app to turn logging off. /dev/null is the unix oubliette, the perfect place for garbage, flames, stupid comments from lusers, etc.

 

In Microsoft Windows/msdos, the equivalent of /dev/null is null: or nul

Log in or register to write something here or to contact authors.