Null device
{{Short description|Device file that discards all data written to it}}
{{For|the electropop band|Null Device}}
{{Confuse|/dev/zero}}
{{Use dmy dates|date=February 2020|cs1-dates=y}}
In some operating systems, the null device is a device file that discards all data written to it but reports that the write operation succeeded. This device is called /dev/null
on Unix and Unix-like systems, NUL:
(see TOPS-20) or NUL
on CP/M and DOS (internally \DEV\NUL
), nul
on OS/2 and newer Windows systems{{Cite web|url=https://support.microsoft.com/en-us/help/110930/redirecting-error-messages-from-command-prompt-stderr-stdout|title=Redirecting Error Messages from Command Prompt: STDERR/STDOUT|website=support.microsoft.com|access-date=2020-03-06}} (internally \Device\Null
on Windows NT), NIL:
on Amiga operating systems,{{cite book |author=Commodore-Amiga, Inc. |title=The AmigaDOS Manual |date=1986 |publisher=Bantam Books |isbn=0-553-34294-0 |page=12 |url=https://archive.org/details/TheAmigaDOSUsersManual3In1Manual/page/n17/mode/2up }} and NL:
on OpenVMS.{{Cite web|url=http://h30266.www3.hpe.com/odl/vax/opsys/vmsos73/vmsos73/5841/5841pro_064.html|title=OpenVMS Programming Concepts Manual|website=h30266.www3.hpe.com|access-date=2020-03-06|archive-date=2020-07-02 |archive-url=https://web.archive.org/web/20200702065120/http://h30266.www3.hpe.com/odl/vax/opsys/vmsos73/vmsos73/5841/5841pro_064.html|url-status=dead}} In Windows Powershell, the equivalent is $null
.{{Cite web|url=https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables|title=about_Automatic_Variables - PowerShell|last=SteveL-MSFT|website=docs.microsoft.com|language=en-us|access-date=2020-03-06}} It provides no data to any process that reads from it, yielding EOF immediately.{{cite web|url=http://www.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap10.html |title=Single Unix Specification Section 10.1: Directory Structure and Files |publisher=The Open Group |access-date=2012-11-29}} In IBM operating systems DOS/360 and successors{{efn|The most recent being z/VSE.}} and also in OS/360 and successors{{efn|The most recent being z/OS.}} such files would be assigned in JCL to DD DUMMY
.
In programmer jargon, especially Unix jargon, it may also be called the bit bucket{{cite web|title=bit bucket|url=http://catb.org/esr/jargon/html/B/bit-bucket.html|work=Jargon File|access-date=2013-12-27}} or black hole.
History
{{mono|/dev/null}} is described as an empty regular file in Version 4 Unix.{{cite book |last1=Thompson |first1=K. |last2=Ritchie |first2=D. M. |author-link1=Ken Thompson |author-link2=Dennis Ritchie |date=November 1973 |title=UNIX Programmer's Manual, Fourth Edition |url=http://ftp.okass.net/pub/mirror/minnie.tuhs.org/Distributions/Research/Dennis_v4/v4man.tar.gz |publisher=Bell Telephone Laboratories, Inc. |no-pp=yes |page=sh (I) (./man1/sh.1)}} [//minnie.tuhs.org/cgi-bin/utree.pl?file=V4/man/man1/sh.1 Online at TUHS.]
The Version 5 Unix manual describes a {{mono|/dev/null}} device with modern semantics.{{cite book |last1=Thompson |first1=K. |last2=Ritchie |first2=D. M. |author-link1=Ken Thompson |author-link2=Dennis Ritchie |date=June 1974 |title=UNIX Programmer's Manual, Fifth Edition |url=http://ftp.okass.net/pub/mirror/minnie.tuhs.org/Distributions/Research/Dennis_v5/v5man.pdf#page=218 |publisher=Bell Telephone Laboratories, Incorporated |no-pp=yes |page=mem (IV)}}
Usage
The null device is typically used for disposing of unwanted output streams of a process, or as a convenient empty file for input streams. This is usually done by redirection. For example, tar -c -f /dev/null "example directory"
can be used to dry-run the TAR file archiving utility to see if any errors would occur but without writing any file.
The /dev/null
device is a special file, not a directory, so one cannot move a whole file or directory into it with the Unix mv
command.
References in computer culture
This entity is a common inspiration for technical jargon expressions and metaphors by Unix programmers, e.g. "please send complaints to /dev/null
", "my mail got archived in /dev/null
", and "redirect to /dev/null
"—being jocular ways of saying, respectively: "don't bother sending complaints", "my mail was deleted", and "go away". The iPhone Dev Team commonly uses the phrase "send donations to /dev/null
", meaning they do not accept donations.{{Cite web|url=http://blog.iphone-dev.org/post/41744653/donations-to-devnull|title=Dev-Team Blog - Donations to /dev/null|date=2015-09-07|access-date=2018-11-15|archive-url=https://web.archive.org/web/20150907154408/http://blog.iphone-dev.org/post/41744653/donations-to-devnull|archive-date=2015-09-07}} The fictitious person name "Dave (or Devin) Null" is sometimes similarly used (e.g., "send complaints to Dave Null").{{cite book |last=Goodman |first=Danny |title=Spam Wars: Our Last Best Chance to Defeat Spammers, Scammers, and Hackers |publisher=SelectBooks |location=New York |year=2004 |url={{Google books|kUp6p5P8wao|page=170|plainurl=yes}} |isbn=9781590790632 |oclc=1036874851 |page=170}} In 1996, Dev Null was an animated virtual reality character created by Leo Laporte for MSNBC's computer and technology TV series The Site. Dev/null is also the name of a vampire hacker in the computer game Vampire: The Masquerade – Redemption. A 2002 advertisement for the Titanium PowerBook G4 reads "Sends other UNIX boxes to /dev/null."{{cite web|url=http://www4.macnn.com/macnn/articles/unixad.jpg |title=Image: unixad.jpg, (1094 × 720 px) |access-date=2015-09-02 |url-status=dead |archive-url=https://web.archive.org/web/20130326010431/http://www4.macnn.com/macnn/articles/unixad.jpg |archive-date=March 26, 2013 }}
The null device is also a favorite subject of technical jokes,{{cite web|url=http://docs.freebsd.org/doc/6.1-RELEASE/usr/share/doc/faq/funnies.html#DEV-NULL |title=The FreeBSD Funnies |publisher=Freebsd.org |access-date=2012-11-28}} such as warning users that the system's /dev/null
is already 98% full. The 1995 April Fool's issue of the German magazine c't reported on an enhanced /dev/null
chip that would efficiently dispose of the incoming data by converting it to a flicker on an internal glowing LED.
Dev/Null is also the name of an electronic dance music producer and jungle DJ.{{Cite magazine |title=Dev Null Microjunglizm |url=https://www.newyorker.com/goings-on-about-town/night-life/devnull-microjunglizm |access-date=2024-01-24 |magazine=The New Yorker |language=en}}
See also
{{columns-list|
- {{mono|:/dev/full}}
- {{mono|:/dev/zero}}
- Device file
- Filesystem Hierarchy Standard
- Memory hole
- rm (Unix)
- Standard streams
- Unix philosophy
- Write-only memory
}}
Notes
{{Notelist}}