Anonymous
Not logged in
Log in
Cosmopedia
Search
View source for /dev/zero
From Wikipedia, the free encyclopedia
Namespaces
Article
Talk
More
More
Page actions
Read
View source
History
←
/dev/zero
You do not have permission to edit this page, for the following reason:
The action you have requested is limited to users in the group:
Users
.
You can view and copy the source of this page:
{{Confuse|Null device}} {{Short description|Special file in Unix-like operating systems}} {{Use dmy dates|date=February 2020|cs1-dates=y}} {{mono|'''/dev/zero'''}} is a [[special file]] in [[Unix-like]] [[operating system]]s that provides as many [[null character]]s ([[ASCII]] NUL, 0x00) as are read from it.<ref>{{citation|title=Advanced Linux Programming|first1=Mark|last1=Mitchell|first2=Jeffrey|last2=Oldham|first3=Alex|last3=Samuel|publisher=Sams Publishing|year=2001|isbn=9780735710436|url=https://books.google.com/books?id=oRqqAVyXjwAC&pg=PA136|contribution=6.5.2 /dev/zero|page=136}}</ref> One of the typical uses is to provide a character stream for initializing data storage.<ref>{{citation|title=Linux System Programming: Talking Directly to the Kernel and C Library|first=Robert|last=Love|publisher=O'Reilly Media, Inc.|year=2007|isbn=9780596009588|url=https://books.google.com/books?id=k_ocKY0iegsC&pg=PA259|contribution=Mapping /dev/zero|pages=259–260}}</ref> ==Function== Read operations from {{mono|/dev/zero}} return as many [[null character]]s (0x00) as requested in the read operation. All write operations to {{mono|/dev/zero}} succeed with no other effects. {{mono|/dev/null}} is more commonly used for this purpose. When {{mono|/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== {{mono|/dev/zero}} was introduced in 1988 in SunOS-4.0 to allow a mappable BSS segment for shared libraries using anonymous memory.<ref>{{cite web |title="C" run-time program bootstrap from SunOS, contributed to CSRG for inclusion in 4.4BSD |url=https://minnie.tuhs.org/cgi-bin/utree.pl?file=4.4BSD/usr/src/contrib/sun.sharedlib/lib/csu/m68k/crt0.s |website=TUHS}}</ref> HP-UX 8.x introduced the MAP_ANONYMOUS flag for mmap(), which maps anonymous memory directly without a need to open {{mono|/dev/zero}}.<ref>{{cite web |title=HP-UX 8.0.7 install media |date=22 July 1992 |url=https://archive.org/details/hp-ux8.07forhp9000s7xx}}</ref> Since the late 1990s, MAP_ANONYMOUS<ref>{{cite web |last1=Beal |first1=Chris |title=So what the heck is anonymous memory |url=https://blogs.oracle.com/cwb/so-what-the-heck-is-anonymous-memory |website=Oracle Blog |access-date=2019-09-09 |archive-date=2021-04-15 |archive-url=https://web.archive.org/web/20210415103111/https://blogs.oracle.com/cwb/so-what-the-heck-is-anonymous-memory |url-status=dead }}</ref> or MAP_ANON are supported by most UNIX versions, removing the original purpose of {{mono|/dev/zero}}.<ref>{{cite web |title=MAP_ANON description in mmap(2) |url=https://netbsd.gw.com/cgi-bin/man-cgi?mmap |website=NetBSD |access-date=2019-09-09 |archive-date=2019-11-25 |archive-url=https://web.archive.org/web/20191125152633/https://netbsd.gw.com/cgi-bin/man-cgi?mmap |url-status=dead }}</ref> ==Examples== {{cite-section|date=January 2026}} [[Data erasure|Erasing]] a [[USB flash drive]] using [[Dd (Unix)|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.{{cn|date=January 2026}} Creating a {{val|1|ul=MiB}} file, named ''[[foobar]]'', filled with null characters: {{sxhl|2=bash|head -c $((1024 * 1024)) /dev/zero >foobar}} ==See also== * [[Unix philosophy]] * [[Standard streams]] * {{mono|[[:/dev]]}} * {{mono|[[:/dev/full]]}} ==References== {{Reflist}} {{DEFAULTSORT:Dev Zero}} [[Category:Unix file system technology]] [[Category:Device file]]
Return to
/dev/zero
.
Navigation
Navigation
Main page
Contents
Current events
Random article
About Wikipedia
contactpage
sitesupport
Contribute
Help
introduction
Community portal
Recent changes
Upload file
Special pages
In other projects
Wiki tools
Wiki tools
Page tools
Page tools
User page tools
More
What links here
Related changes
Page information
Page logs