Description of ">/dev/null 2>&1" related knowledge under Linux

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.