Which sequence sends only standard error to a file while leaving standard output untouched?

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

Which sequence sends only standard error to a file while leaving standard output untouched?

Explanation:
In Unix-like shells, standard output is file descriptor 1 and standard error is file descriptor 2. To send only the error messages to a file while keeping normal output on the screen, you redirect the second descriptor. The syntax 2> file.txt does exactly that: it sends only stderr to file.txt, leaving stdout untouched. The other options redirect stdout ( > file.txt or 1> file.txt ) or redirect both streams ( &> file.txt ), which isn’t what the question asks.

In Unix-like shells, standard output is file descriptor 1 and standard error is file descriptor 2. To send only the error messages to a file while keeping normal output on the screen, you redirect the second descriptor. The syntax 2> file.txt does exactly that: it sends only stderr to file.txt, leaving stdout untouched. The other options redirect stdout ( > file.txt or 1> file.txt ) or redirect both streams ( &> file.txt ), which isn’t what the question asks.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy