| This article does not cite any references or sources. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. (July 2009) |
/dev/zero is a special file in Unix-like operating systems that provides as many null characters (ASCII NUL, 0x00) as are read from it. One of the typical uses is to provide a character stream for initializing data storage.
Function
Read operations from /dev/zero return as many null characters (0x00) as requested in the read operation.
Like /dev/null, /dev/zero may be used not only as a source, but also as a sink for data. All write operations to /dev/zero succeed with no other effects. However, /dev/null is more commonly used for this purpose.
When /dev/zero is memory-mapped, e.g., with mmap, to the virtual address space, it is equivalent to using anonymous memory, i.e. memory not connected to any file.
Examples
The dd Unix utility program reads octet streams from a source to a destination, possibly performing data conversions in the process. Destroying existing data on a file system partition:
dd if=/dev/zero of=/dev/<destination partition>
Creating a 1 MiB file, called foobar, filled with zeroes:
dd if=/dev/zero of=foobar count=1024 bs=1024
See also
| This Unix-related article is a stub. You can help Wikipedia by expanding it. |
This entry is from Wikipedia, the leading user-contributed encyclopedia. It may not have been reviewed by professional editors (see full disclaimer)




