In the process of learning Linux, often see some terminal commands or programs have ">/dev/null 2>&1" appear, because have met several times, in order to understand clearly, may wish to spend some time Baidu or Google related knowledge.
0: Indicates keyboard input (stdin)
1: Indicates standard output (stdout), system default is 1
2: Indicates error output (stderr)
Command >/dev/null 2>&1 & = = Command 1>/dev/null 2>&1 &
1) Command: Represents a shell command or an executable program
2);: indicates where to redirect
3)/dev/null: Empty device file representing Linux
4) 2: Indicates standard error output
5) &1:& means equivalent, 2>&1, indicating that 2 of the output redirect equals 1
6) &: Indicates background execution, that is, this instruction execution runs in the background
1>/dev/null: Indicates that standard output is redirected to an empty device file, which means no information is output to the terminal and no information is displayed.
2>&1: Indicates that the standard error output redirection is equivalent to standard output because the standard error output is also redirected to an empty device file because the standard output was previously redirected to an empty device file.
This command means to execute the program in the background and redirect the error output 2 to standard output 1, and then put the standard output 1 all into the/dev/null file, which is empty.
So you can see ">/dev/null 2>&1" commonly used to avoid shell commands or programs, such as the content output in the run.
Description of ">/dev/null 2>&1" related knowledge under Linux