E-Mail:
Get our new Windows 7 eBook (PDF) for $7 with 70+ Tips. Download Now!

The Zero Files

  • No Related Post

The Zero Files

Writing data to a device that ignores it. Reading empty data from a device. Sounds like a trip into the Twilight Zone, huh? Or a visit to a Linux nightmare. Believe it or not, these can actually be useful activities in Linux. In fact, there are two device files in Linux created specifically for these purposes.

/dev/null is, in fact, a byte sink. That’s to say that whatever you send to /dev/null simply goes away because the device ignores it. In my high-powered procmail-based mail filtering system, I use /dev/null extensively to write unwanted emails to the deep black cyber void. The process is seen as complete by the system because it’s done exactly what was intended - stored data nowhere.

Even casual Linux users know about /dev/null. /dev/zero is a lesser-known counterpart to /dev/null. Rather than ignoring data sent to it, /dev/zero can be used to write an empty file. In other words, any request sent to /dev/zero will return holding an empty bag. As with /dev/null, the process completes - it just completes with no data. We showed an example of this a few days ago in creating a swap file:

    dd if=/dev/zero of=/swap bs=1024 count=8192

The most useful result of data handling isn’t always storage or retrieval. Sometimes it’s nothing.

What Do You Think?

 
35 queries / 0.353 seconds.