What does the redirection '2> /dev/null' accomplish in a shell command?

Study for the OSCP Linux Exam. Use our flashcards and multiple-choice questions to test your skills. Each query comes with detailed hints and explanations to enhance your preparedness. Get ready to conquer the exam!

Multiple Choice

What does the redirection '2> /dev/null' accomplish in a shell command?

Explanation:
The redirection 2> /dev/null targets the standard error stream and sends it to /dev/null, a special sink that discards everything written to it. In shells, file descriptor 2 is standard error, while 1 is standard output and 0 is standard input. The command 2> /dev/null therefore silences error messages while leaving normal output alone (unless you also redirect that). If you wanted to suppress both outputs, you’d redirect stdout as well and/or use a combined form like command > /dev/null 2>&1.

The redirection 2> /dev/null targets the standard error stream and sends it to /dev/null, a special sink that discards everything written to it. In shells, file descriptor 2 is standard error, while 1 is standard output and 0 is standard input. The command 2> /dev/null therefore silences error messages while leaving normal output alone (unless you also redirect that). If you wanted to suppress both outputs, you’d redirect stdout as well and/or use a combined form like command > /dev/null 2>&1.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy