special computer file that discards all writes
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 … Wikipedia
🌐
Wikipedia
https://en.wikipedia.org › wiki › Null_device
Null device - Wikipedia
September 21, 2026 - 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 (internally \Device\Null on Windows NT), NIL: on Amiga operating systems, and NL: on OpenVMS.
🌐
GeeksforGeeks
https://geeksforgeeks.org › linux-unix › what-is-dev-null-in-linux
What is /Dev/Null in Linux? - GeeksforGeeks
July 31, 2023 - This command replaces the contents of 'sensitive_file' with null bytes, ensuring its secure deletion. Log files can accumulate substantial data over time. To clear log files without interrupting running services, you can redirect their content ...
Discussions

linux - What does "/dev/null" mean at the end of shell commands - Stack Overflow
What is the difference between the following commands? ssh myhostname "command1; command2;...commandn;" 2>/dev/null ssh myhostname "command1; command2;...commandn;" what does 2> mean? what ... More on stackoverflow.com
🌐 stackoverflow.com
Purpose of /dev/null
And remember, if you outgrow the capabilities of local /dev/null, you can burst into the cloud https://devnull-as-a-service.com/ More on reddit.com
🌐 r/linux
42
47
August 13, 2017
Does "/dev/null" always exist ?
POSIX requires a /dev/null to be present ...so there is a good chance that it's usually available. But of course there are no guarantees, nobody is stopping anyone to create an intentional POSIX violating linux system. No clue about MacOS..but as MacOS claims to be posix compliant it must have /dev/zero. edit:typos More on reddit.com
🌐 r/linuxquestions
67
72
February 9, 2022
ELI5: How does /dev/null work?
The kernel represents it as a file where all operations to the file are no-ops. Here is the source code. EDIT: Hm, that's probably not ELI5. Basically, it's a special file constructed by the kernel where reading and writing into the file doesn't do anything, it simply immediately returns success to the user. More on reddit.com
🌐 r/linux
24
26
March 15, 2014
People also ask

What is the difference between `> /dev/null` and `2> /dev/null`?
`> /dev/null` discards standard output and leaves error messages visible. `2> /dev/null` discards standard error and leaves normal output visible.
🌐
linuxize.com
linuxize.com › home › bash › what is /dev/null in linux
What Is /dev/null in Linux | Linuxize
Are /dev/zero and /dev/null the same?
No. `/dev/null` returns nothing when read, while `/dev/zero` returns an endless stream of null bytes. Both discard anything written to them, but only `/dev/zero` produces data on read.
🌐
linuxize.com
linuxize.com › home › bash › what is /dev/null in linux
What Is /dev/null in Linux | Linuxize
Is /dev/null a real file?
It is a special device file provided by the kernel, not a regular file on disk. Writing to it discards data, and reading from it returns end-of-file immediately.
🌐
linuxize.com
linuxize.com › home › bash › what is /dev/null in linux
What Is /dev/null in Linux | Linuxize
🌐
NullDev
https://nulldev.info
NullDev
NullDev is a small team of self-taught programmers. We aim to help people like you create and realize their ideas. We can tackle all kinds of different projects, from APIs to web, mobile, and desktop applications.
🌐
GitHub
https://github.com › NullDev
NullDev (Chris) · GitHub
Fullstack (backend focus) Developer and Comp-Sci & Math student with huge interests in Artificial Intelligence and Machine Learning. - NullDev
🌐
NullDev
https://nulldev.org
NullDev | Home
Hey! I'm Chris aka NullDev. I'm a fullstack developer with focus on backend programming and artificial intelligence / machine learning. I am also currently studying computer science and mathematics. A better overview of what I do, can be found on my GitHub. I'm currently open for (freelance) ...
🌐
GitHub
https://github.com › NullDev › NullDev
GitHub - NullDev/NullDev: :octocat: My GitHub profile ReadMe
Hey! I'm Chris aka NullDev. I'm a 26 year old fullstack developer with focus on backend programming and artificial intelligence / machine learning who likes Math and Functional Programming a bit too much.
Author: NullDev
Find elsewhere
🌐
Product Hunt
https://producthunt.com › home › /dev/null
/dev/null: a social network for devs | Product Hunt
4 days ago - /dev/null started as a live stream from the JetBrains office. On Oct 15, 2026, Nuno Maduro, Brent Roose, Matthieu Napoli, and Pauline Vos built a social network for web developers from scratch in 48 hours, in the open. Sign in with GitHub, share code snippets, like, reply, etc, etc!
Rating: 5 ​ - ​ 1 votes
🌐
Linuxize
https://linuxize.com › home › bash › what is /dev/null in linux
What Is /dev/null in Linux | Linuxize
September 30, 2026 - The Linux /dev/null device discards anything written to it and returns EOF when read. This guide shows how to silence stdout, stderr, cron output, and empty files.
🌐
Stack Overflow
https://stackoverflow.com › users › 7575111 › nulldev
User NullDev - Stack Overflow
NullDev · Full-stack/Backend developer · Member for 8 years, 10 months · Last seen this week · Twitter · GitHub · nulldev.org · Austria · Profiles · Meta user · Network profile · Profile Activity · 7,378 reputation · 520k reached ...
🌐
Wiktionary
https://en.wiktionary.org › wiki › › dev › null
/dev/null - Wiktionary, the free dictionary
From Unix operating systems, where /dev (the Unix directory containing device files) contains a null entry representing no device.
🌐
DigitalOcean
https://digitalocean.com › community › tutorials › dev-null-in-linux
/dev/null in Linux | DigitalOcean
August 3, 2022 - File: /dev/null Size: 0 Blocks: 0 IO Block: 4096 character special file Device: 6h/6d Inode: 5 Links: 1 Device type: 1,3 Access: (0666/crw-rw-rw-) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2020-02-04 13:00:43.112464814 +0530 Modify: 2020-02-04 13:00:43.112464814 +0530 Change: 2020-02-04 13:00:43.112464814 +0530
🌐
GitHub
https://github.com › null-d-e-v
null-d-e-v (null-d-e-v) · GitHub
null-d-e-v/README.md · 🚀 Developer | 💻 Tech Enthusiast · Efficiency, scalability, and performance for robust services. Seamless and interactive experiences with modern technologies. @null_dev_ on Discord ·
🌐
Null
https://dev.null.org
the null device
This is the new front page; the blog is still accessible here · blog code some dodgy fonts lost treasures links
Top answer
1 of 2
4

No, the easiest way would be to not write it anywhere at all. The data doesn't have to go somewhere before being discarded – it can be discarded before it goes there.

In general, when you read or write a file, you're not directly accessing a disk, you're just asking the OS kernel to read or write a file, so the kernel has authority on deciding whether that file is going to be stored on disk or not. With files like /dev/null, there is no reason for writes to end up on actual storage – if the kernel recognizes that you're writing to the special "null" device, it can just discard them long before that happens.

There are several ways this could be implemented:

  • You can have reserved file names that are recognized by OS.

    This is almost never done in Linux, but it's how the equivalent NUL file works in Windows and MS-DOS. Whenever a program in Windows tries to write to a file named "nul", those writes are discarded before they even reach the filesystem driver, much less the actual disk.

  • You can have special file attributes that activate specific handling.

    On Linux (and other Unix systems), most items in /dev have their own distinct type – they are not regular files but device files, one of several types1 of Unix special files. They do exist on disk, but only as a name – there's never any actual storage allocated to them; when a device file is opened, the kernel uses custom handlers for read/write operations (instead of letting the filesystem do it).

    If you run ls -l /dev, you will see the first column showing b or c as the item type ("block" or "character" subtypes), and the size column being replaced by a pair of "major, minor" values that tell the kernel how to handle access to that device. The mknod command can be used to create such objects.

    For example, in Linux, /dev/null is listed as having major number 1, which is handled by drivers/char/mem.c. Within that file, minor number 3 is handled through the null_fops table. In this structure, the "write" handler is set to write_null, which does... literally nothing.

    All other /dev nodes have their special behavior implemented in the same way. For example, /dev/ttyS0 is associated with "fops" functions that read from a physical serial port. (In the Linux source, look for "register_chardev" and "misc_register" functions; in BSD sources, look for a giant "cdevsw" list that enumerates each major type.)

    1 There are also more special file types – symbolic links (ln -s); named pipes (mkfifo); sockets; doors (Solaris); whiteouts (NetBSD) – all of which are handled specially and don't occupy any disk storage.

  • You can also have whole filesystems that do something different than storing files on disk.

    Typically you can mount different disks at different filesystem paths (e.g. / or C:\ is your SSD, /data or D:\ is your HDD, /media/sandisk or E:\ is your USB stick), with the OS associating each location with a specific filesystem driver and a specific physical device.

    However, the OS may also support virtual filesystem types that don't use a physical device.

    For example, on Linux, the entire /dev is usually mounted from a tmpfs filesystem, which behaves like a normal filesystem but uses only RAM as its storage. Even if you create completely regular files in /dev and start writing data to them, it will be stored in RAM only – not on any disk. Sometimes /tmp is a tmpfs, too.

    (In the past, a similar result was achieved by mounting a regular filesystem but giving it a "RAM disk" – i.e. just a dedicated region of RAM – as the storage device. You'll still find ramdisk software for Windows, which has no tmpfs equivalent.)

    The /proc and /sys directories also have special filesystems mounted on them, so the entire contents of /proc are entirely virtual. (Because of this, even though they look like regular files and not device files, they still show all kinds of irregular behavior.)

2 of 2
3

The data is not stored and discarded, it's just discarded.

pg@TREX:~$ ls -l /dev/null
crw-rw-rw- 1 root root 1, 3 Sep 18 08:09 /dev/null

As you can see /dev/null is a character device. Data streams there unbuffered, character by character and gets immediately discarded, character by character. It contains nothing, so if you try to read from it, the only thing it gives back is EOF => cat /dev/null > filename creates a zero-byte file.

As the data never gets stored, using /dev/null doesn't degrade your drive.

Some articles about or touching /dev/null:

  • https://www.networkworld.com/article/3025497/sending-data-into-the-void-with-dev-null.html
  • https://tldp.org/LDP/abs/html/zeros.html
  • http://ibgwww.colorado.edu/~lessem/psyc5112/usail/concepts/filesystems/everything-is-a-file.html
🌐
GeeksforGeeks
https://geeksforgeeks.org › what-is-dev-null-in-linux
What is /Dev/Null in Linux? - GeeksforGeeks
July 31, 2023 - This command replaces the contents of 'sensitive_file' with null bytes, ensuring its secure deletion. Log files can accumulate substantial data over time. To clear log files without interrupting running services, you can redirect their content ...
🌐
Linux Man Pages
https://man7.org › linux › man-pages › man4 › zero.4.html
null(4) - Linux manual page
Data written to the /dev/null and /dev/zero special files is discarded. Reads from /dev/null always return end of file (i.e., read(2) returns 0), whereas reads from /dev/zero always return bytes containing zero ('\0' characters).
🌐
Linux Handbook
https://linuxhandbook.com › dev-null
What is /dev/null in Linux?
October 19, 2023 - It is a virtual file with a unique way of dealing with files. Anything written on /dev/null will disappear and can not be recovered. A command is supposed to generate huge output?
🌐
UbuntuMint
https://ubuntumint.com › home › linux commands › what is /dev/null in linux
What is /dev/null (Virtual Null Device) in Linux
August 25, 2023 - In such cases, ‘/dev/null‘ comes in handy. This file is used as a ‘sink‘, i.e. a target file to write the log.