{{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 <code>/dev/null</code> on Unix and Unix-like systems, <code>NUL:</code> (see TOPS-20) or <code>NUL</code> on CP/M and DOS (internally <code>\DEV\NUL</code>), <code>nul</code> on OS/2 and newer Windows systems<ref>{{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}}</ref> (internally <code>\Device\Null</code> on Windows NT), <code>NIL:</code> on Amiga operating systems,<ref>{{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 }}</ref> and <code>NL:</code> on OpenVMS.<ref>{{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}}</ref> In Windows Powershell, the equivalent is <code>$null</code>.<ref>{{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}}</ref> It provides no data to any process that reads from it, yielding EOF immediately.<ref name="uxman">{{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}}</ref> 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 <code>DD DUMMY</code>.

In programmer jargon, especially Unix jargon, it may also be called the bit bucket<ref>{{cite web|title=bit bucket|url=http://catb.org/esr/jargon/html/B/bit-bucket.html|work=Jargon File|access-date=2013-12-27}}</ref> or black hole.

==History== {{mono|/dev/null}} is described as an empty regular file in Version 4 Unix.<ref>{{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.]</ref>

The Version 5 Unix manual describes a {{mono|/dev/null}} device with modern semantics.<ref>{{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)}}</ref>

==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, <code>tar -c -f /dev/null "example directory"</code> can be used to dry-run the TAR file archiving utility to see if any errors would occur but without writing any file.

The <code>/dev/null</code> device is a special file, not a directory, so one cannot move a whole file or directory into it with the Unix <code>mv</code> command.

Unix shell command <code>cat /dev/null</code> would do nothing, equivalent to <code>true</code> or <code>:</code> 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 <code>/dev/null</code>", "my mail got archived in <code>/dev/null</code>", and "redirect to <code>/dev/null</code>"—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 <code>/dev/null</code>", meaning they do not accept donations.<ref>{{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}}</ref> The fictitious person name "Dave (or Devin) Null" is sometimes similarly used (e.g., "send complaints to Dave Null").<ref name="Goodman 2004 p. 170">{{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}}</ref> 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."<ref name="macnn">{{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 }}</ref>

The null device is also a favorite subject of technical jokes,<ref>{{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}}</ref> such as warning users that the system's <code>/dev/null</code> is already 98% full. The 1995 April Fool's issue of the German magazine ''c't'' reported on an enhanced <code>/dev/null</code> 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.<ref>{{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}}</ref>

== See also == {{columns-list| * {{mono|:/dev/full}} * {{mono|:/dev/zero}} * Device file * Filesystem Hierarchy Standard * Memory hole * {{mono|rm}} (Unix) * Standard streams * Unix philosophy * Write-only memory }}

== Notes == {{Notelist}}

== References == {{Reflist|60em}}

{{nulls}}

Category:CP/M technology Category:Unix file system technology Category:Device file Category:Computer humour