By default, there are always three files open, standard input (keyboard input), standard output (output to screen), standard error (also output to screen), and their respective file descriptors are 0,1,2. So let's take a look at the differences between the following redirection methods:
>/dev/null 2>&1
In fact, it should be equivalent to this: 1>/dev/null 2>/dev/null, by default is 1, standard output, so generally omitted. The & symbol, followed by the required file descriptor. cannot be written as 2>1, so it becomes a standard error redirect to a file named 1, instead of redirecting standard errors to standard output. So here it is: The standard output is redirected to the/dev/null, and the standard error is redirected to the standard output, so the standard output and standard error are redirected to the/dev/null
2>&1 >/dev/null
At first glance, what's the difference between this and that one? Standard error redirected to standard output, and standard output redirected to/dev/null? Shouldn't we all redirect/dev/null at the end? That's how I understand it! An instruction either produces a standard error at the same time or produces a standard output. When the output standard is wrong, the standard error is redirected to the standard output, and the standard output is output to the screen. At this point the standard output was not redirected to/dev/null, so it was printed on the screen. When the standard output is produced, then it is not a standard error, 2>&1 is not valid, so the standard output redirects dev/null, does not print to the screen. So the end result will be: standard error printing to the screen, and standard output not printing to the screen.
From:http://blog.csdn.net/reyleon/article/details/11595985
The difference between >/dev/null 2>&1 and 2>&1 >/dev/null and &>/dev/null in the shell