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:
- 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!)
- 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’)
Similar Posts:
- > Here Boy, Go Fetch! May 19, 2021
- > non-KDE app filechooser trick May 12, 2009
- > Solving arrays – problem #1: Closest to zero July 30, 2010
- > Removing Null Values In A List Using Java 8 Stream October 22, 2020
- > shared nothing October 3, 2006
Notice: This article was published on October 9, 2006 and the content above may be out of date.