The “/dev/null” file is a special file that can be found in all Linux systems. They are also referred to as “null device files”, “void”, and sometimes “a black hole of Linux”.
There is not any specific role for this file; however, if you redirect anything to it, it will be discarded or forgotten in limbo without any trace.
But before you understand them deeply, you must also be aware of the concept of stdin, stdout, and stderr streams in Linux.
Tutorial Details
| Description | /dev/null or null device file |
| Difficulty Level | Moderate |
| Root or Sudo Privileges | No |
| OS Compatibility | Ubuntu, Manjaro, Fedo… |
The “/dev/null” file is a special file that can be found in all Linux systems. They are also referred to as “null device files”, “void”, and sometimes “a black hole of Linux”.
There is not any specific role for this file; however, if you redirect anything to it, it will be discarded or forgotten in limbo without any trace.
But before you understand them deeply, you must also be aware of the concept of stdin, stdout, and stderr streams in Linux.
Tutorial Details
| Description | /dev/null or null device file |
| Difficulty Level | Moderate |
| Root or Sudo Privileges | No |
| OS Compatibility | Ubuntu, Manjaro, Fedora, etc. |
| Prerequisites | cat, file, stat, echo |
| Internet Required | No |
/dev/null File Information
If you read this file using the cat command, it will return the EOF (end of file) characters (nothing).
$ cat /dev/null
Output:
However, if you check the type of this file using the file command, you will get the following output.
$ file /dev/null
Output:
But if you check the file information using the stat command, you will get some more juicy information.
$ stat /dev/null
Output: