/dev/zero
Script error: No such module "Distinguish". Template:Short description Template:DMCA Page Template:Mono/styles.css has no content./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.[1] One of the typical uses is to provide a character stream for initializing data storage.[2]
Function
Read operations from Page Template:Mono/styles.css has no content./dev/zero return as many null characters (0x00) as requested in the read operation.
All write operations to Page Template:Mono/styles.css has no content./dev/zero succeed with no other effects. Page Template:Mono/styles.css has no content./dev/null is more commonly used for this purpose.
When Page Template:Mono/styles.css has no content./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.
History
Page Template:Mono/styles.css has no content./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 Page Template:Mono/styles.css has no content./dev/zero.[4] Since the late 1990s, MAP_ANONYMOUS[5] or MAP_ANON are supported by most UNIX versions, removing the original purpose of Page Template:Mono/styles.css has no content./dev/zero.[6]
Examples
Page Module:Message box/ambox.css has no content.
This section needs additional citations for verification. (January 2026) |
Erasing a USB flash drive using DD:
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 a 1 MiB file, named foobar, filled with null characters:
head -c $((1024 * 1024)) /dev/zero >foobar
See also
- Unix philosophy
- Standard streams
- Page Template:Mono/styles.css has no content./dev
- Page Template:Mono/styles.css has no content./dev/full
References
Page Template:Reflist/styles.css has no content.
- ^ Page Module:Citation/CS1/styles.css has no content.Mitchell, Mark; Oldham, Jeffrey; Samuel, Alex (2001), "6.5.2 /dev/zero", Advanced Linux Programming, Sams Publishing, p. 136, ISBN 9780735710436
- ^ Page Module:Citation/CS1/styles.css has no content.Love, Robert (2007), "Mapping /dev/zero", Linux System Programming: Talking Directly to the Kernel and C Library, O'Reilly Media, Inc., pp. 259–260, ISBN 9780596009588
- ^ Page Module:Citation/CS1/styles.css has no content.""C" run-time program bootstrap from SunOS, contributed to CSRG for inclusion in 4.4BSD". TUHS.
- ^ Page Module:Citation/CS1/styles.css has no content."HP-UX 8.0.7 install media". 1992-07-22.
- ^ Page Module:Citation/CS1/styles.css has no content.Beal, Chris. "So what the heck is anonymous memory". Oracle Blog. Archived from the original on 2021-04-15. Retrieved 2019-09-09.
- ^ Page Module:Citation/CS1/styles.css has no content."MAP_ANON description in mmap(2)". NetBSD. Archived from the original on 2019-11-25. Retrieved 2019-09-09.