/dev/zero

From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by imported>Kbrose at 16:10, 29 December 2025 (clean out advice). The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Script error: No such module "Distinguish". Template:Short description Template:Use dmy dates <templatestyles src="Mono/styles.css" />/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 <templatestyles src="Mono/styles.css" />/dev/zero return as many null characters (0x00) as requested in the read operation.

All write operations to <templatestyles src="Mono/styles.css" />/dev/zero succeed with no other effects. However, <templatestyles src="Mono/styles.css" />/dev/null is more commonly used for this purpose.

When <templatestyles src="Mono/styles.css" />/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

<templatestyles src="Mono/styles.css" />/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 <templatestyles src="Mono/styles.css" />/dev/zero.[4] Since the late 1990s, MAP_ANONYMOUS[5] or MAP_ANON are supported by most UNIX versions, removing the original purpose of <templatestyles src="Mono/styles.css" />/dev/zero.[6]

Examples

Erasing a file system partition or drive:

cp /dev/zero /dev/<destination drive or partition>

However, this may not perform a secure erasure, may not destroy the data at all, and may take significantly more time than required–for this purpose.

Creating a Script error: No such module "val". file, called foobar, filled with null characters:

Template:Sxhl

See also

References

<templatestyles src="Reflist/styles.css" />

  1. Script error: No such module "citation/CS1".
  2. Script error: No such module "citation/CS1".
  3. Script error: No such module "citation/CS1".
  4. Script error: No such module "citation/CS1".
  5. Script error: No such module "citation/CS1".
  6. Script error: No such module "citation/CS1".

Script error: No such module "Check for unknown parameters".