/dev/zero

Posted: October 9, 2006 in linux

Found in Linux and Unix operating systems, /dev/zero is a special file that provides null characters (ASCII character NULL – 0x00; not ASCII character “zero” or “0” – 0x30). While it may seem similar to the special file /dev/null, it actually does the opposite. The file /dev/null acts as a data sink, an imaginary “black hole,” where all writes to it are discarded and no data is returned from processes reading from it. On the other hand /dev/zero acts as a source. All writes to /dev/zero are successful (the same goes for /dev/null).

Uses:

  1. Used to wipe data from a file. /dev/zero can fill out a file with null characters. (It is not sufficient to use this method for wiping out file data from disk.)
    ~# dd if=/dev/zero of=/dev/hda2
    (Note: The following command will erase all files that are in the partition. Try at your own risk!)
  2. Can generate a new file of a certain size.
    ~# dd if=/dev/zero of=foobar bs=1024 count=1
    (Creates an empty file called ‘foobar’)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s