Clever Geek Handbook
📜 ⬆️ ⬇️

/ dev / null

/ dev / null is a special file on UNIX class systems , which is a so-called “empty device”. Writing to it is successful, regardless of the amount of "recorded" information. Reading from / dev / null is equivalent to reading end of file ( EOF ).

UNIX device file / dev / null .
Type of:symbolic ( c )
OSmajorminor
Solaris132
Linux , FreeBSDone3

DOS has a NUL pseudo-file with similar properties.

Content

  • 1 Creation
  • 2 Usage Examples
  • 3 Jargon
  • 4 See also

Creation

The / dev / null pseudo-device is considered symbolic . It is created using the mknod utility as follows:

On Linux :

  mknod FILE c 1 3

In FreeBSD :

  mknod FILE c 0 27

In Solaris :

  mknod FILE c 13 2

Here FILE is the name for the new empty device. At the stage of system installation, it is created in this way with the "standard" name /dev/null .

Use

  • Most often, redirection in / dev / null is used to suppress standard output (output stream) and / or output error messages (diagnostic stream) of the program by redirecting it to / dev / null, this suppression is most often used in shell scripts suppressing unwanted output to the console.

The output of the standard output stream (STDOUT) and the error stream (STDERR) in / dev / null:

  do something > / dev / null 2> & 1

In modern bash shells, to redirect standard output (STDOUT) and error stream (STDERR) to / dev / null it is recommended to use:

  do something &> / dev / null

Error stream output (STDERR) in / dev / null:

  do something 2> / dev / null
  • Launch the reader program, which expects the name of the input file as a required parameter, without one.
  reader / dev / null
  • Checking the availability of all files in the foo directory and its subdirectories for reading.
  find foo / -type f -readable> / dev / null
  • It is very convenient to use to zero large files, for example, mailboxes:
  cp / dev / null / var / mail / mike

Jargon

In the jargon of system administrators and software developers, null is associated with a lack of information. For example, “my mail is saved to null” means that all incoming mail is deleted, “send complaints to null” means not to bother with complaints, “send donations to null” means that donations are not accepted, and “redirect to null” means to send away or ignore.

See also

  • / dev / zero
  • / dev / full
  • / dev / random and / dev / urandom
  • / dev


Source - https://ru.wikipedia.org/w/index.php?title=/dev/null&oldid=97671239


More articles:

  • Eucerotinae
  • Rybakov, Yuri Sergeevich
  • Meryansky language
  • Sippo, Teemu
  • Guy Mari Quiz
  • St. John's Bridge
  • Alberada Buonalbergo
  • Heroes of Socialist Labor of the Leningrad Region
  • Museum of the Mologsky Krai named after N. M. Alekseev
  • Menges, Chris

All articles

Clever Geek | 2019