/dev/zero is aspecial file inUnix-likeoperating systems that provides as manynull characters (ASCII NUL, 0x00) as are read from it.[1] One of the typical uses is to provide a character stream for initializing data storage.[2]
Read operations from/dev/zero return as manynull characters (0x00) as requested in the read operation.
All write operations to/dev/zero succeed with no other effects./dev/null is more commonly used for this purpose.
When/dev/zero is memory-mapped, e.g., withmmap, to the virtual address space, it is equivalent to using anonymous memory; i.e. memory not connected to any file.
/dev/zero was introduced in 1988 in SunOS-4.0 to allow a mappable BSS segment for shared libraries using anonymous memory.[3] HP-UX 8.x introduced the MAP_ANONYMOUS flag for mmap(), which maps anonymous memory directly without a need to open/dev/zero.[4] Since the late 1990s, MAP_ANONYMOUS[5] or MAP_ANON are supported by most UNIX versions, removing the original purpose of/dev/zero.[6]
This sectionneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources in this section. Unsourced material may be challenged and removed.(January 2026) (Learn how and when to remove this message) |
Erasing aUSB flash drive usingDD:
dd if=/dev/zero of=/dev/<destination drive>
This may not perform a secure erasure and may not destroy any data, but may take significantly more time than required for this purpose.[citation needed]
Creating a1 MiB file, namedfoobar, filled with null characters:
head-c$((1024*1024))/dev/zero>foobar