/dev/zero
Special file in Unix-like operating systems
title: "/dev/zero" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["unix-file-system-technology", "device-file"] description: "Special file in Unix-like operating systems" topic_path: "technology/operating-systems" source: "https://en.wikipedia.org/wiki//dev/zero" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0
::summary Special file in Unix-like operating systems ::
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 return as many null characters (0x00) as requested in the read operation.
All write operations to succeed with no other effects. is more commonly used for this purpose.
When 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.
History
was introduced in 1988 in SunOS-4.0 to allow a mappable BSS segment for shared libraries using anonymous memory. HP-UX 8.x introduced the MAP_ANONYMOUS flag for mmap(), which maps anonymous memory directly without a need to open . Since the late 1990s, MAP_ANONYMOUS or MAP_ANON are supported by most UNIX versions, removing the original purpose of .
Examples
Erasing a USB flash drive using DD:
dd if=/dev/zero of=/dev/
This may not perform a secure erasure and may not destroy any data, but may take significantly more time than required for this purpose.
Creating a file, named foobar, filled with null characters:
References
References
- (2001). "Advanced Linux Programming". Sams Publishing.
- Love, Robert. (2007). "Linux System Programming: Talking Directly to the Kernel and C Library". O'Reilly Media, Inc..
- ""C" run-time program bootstrap from SunOS, contributed to CSRG for inclusion in 4.4BSD".
- (22 July 1992). "HP-UX 8.0.7 install media".
- "So what the heck is anonymous memory".
- "MAP_ANON description in mmap(2)".
::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::