Special device files
/dev/full
/dev/null
/dev/random
and /dev/urandom
/dev/zero
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: or NUL on DOS and CP/M, nul on newer Windows systems (internally \Device\Null on Windows NT), NIL: on Amiga operating systems, and the NL: on OpenVMS. In Windows Powershell, the equivalent is $null. It provides no data to any process that reads from it, yielding EOF immediately. In IBM DOS/360, OS/360 (MFT, MVT), OS/390 and z/OS operating systems, such files would be assigned in JCL to DD DUMMY.
In programmer jargon, especially Unix jargon, it may also be called the bit bucket or black hole.
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.
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. The rm command is the proper way to delete files in Unix.
some command > /dev/null 2>&1
STDIN is represented by 0, STDOUT by 1, and STDERR by 2.
/dev/null is the bit-bucket: the place where you dump anything you don’t need.
By default:
stdin ==> fd 0
stdout ==> fd 1
stderr ==> fd 2
In the script, you use > /dev/null
causing:
stdin ==> fd 0
stdout ==> /dev/null
stderr ==> fd 2
And then 2>&1
causing:
stdin ==> fd 0
stdout ==> /dev/null
stderr ==> stdout
Reference: https://en.wikipedia.org/wiki/Null_device
https://unix.stackexchange.com/questions/119648/redirecting-to-dev-null