The typical command output channel is called `STDOUT`. For example, when you run `ls -la` you will get a detailed directory listing on your screen/console. This listing is sent on STDOUT. But if something goes wrong and your command generates an error message, this information is sent in a different stream, called `STDERR`. By default, STDERR is handled the same way as STDOUT, and appears on the console.
If you redirect the output of a command to a text file (for example, `ls -la > listing.txt`), and your command generates an error, this error message will be recorded in the text file. But what if you don’t want to have the error message go to the same place as the command’s output?
There is a command line shorthand to refer to STDOUT and STDERR, and you can use this shorthand to choose what to do with each stream. This shorthand is called file descriptors. STDOUT’s file descriptor is 1, and STDERR’s file descriptor is 2.
By adding the 2>/dev/null, the error message (STDERR, or file descriptor 2) is redirected, in this case to /dev/null, leaving only STDOUT to appear on the screen.
You could also use STDERR redirection to log errors separately. For example, if a command is scheduled to run on a regular basis, you can append any error messages to a log file, by adding 2>>/path/to/logfile.txt. Each time the command generates an error, the error message will be added to the end of logfile.txt.
For a really good set of examples, see this Stack Overflow page. This syntax works in Linux, OSX/MacOS, and Windows. Figuring this out was a monolith-moment for me.