Which of the following strings should be appended to the command?

To prevent a command run as root from sending both standard out (stdout) and standard error (stderr) to any terminal or other file or device.

Which of the following strings should be appended to the command?

To prevent a command run as root from sending both standard out (stdout) and standard error (stderr) to any terminal or other file or device.

Which of the following strings should be appended to the command?

A.
>/dev/null

B.
>/dev/null 1>&2

C.
>/dev/null 2>&1

D.
1>&2 >/dev/null

E.
2>&1 >/dev/null

Explanation:
A) redirects only stdout
B) would send stdout to /dev/null, then redirect is to stderr, putting all output to stderr
D) would first redirect stdout to stderr, then redirect stdout to /dev/null, leaving stderr as it is
E) would first redirect stderr to stdout, then only stdout to /dev/null, leaving stderr on stdout

cmd &> /dev/null would have the same result as C



Leave a Reply 0

Your email address will not be published. Required fields are marked *