Bird
0
0

Which command discards both standard output and standard error using /dev/null?

easy📝 Conceptual Q2 of 15
Linux CLI - Pipes and Redirection
Which command discards both standard output and standard error using /dev/null?
Acommand >& /dev/null
Bcommand 2> /dev/null
Ccommand > /dev/null 2>&1
Dcommand > /dev/null
Step-by-Step Solution
Solution:
  1. Step 1: Understand redirection syntax for stdout and stderr

    Standard output is redirected with >, standard error with 2>. To redirect both, use 2>&1 to merge stderr into stdout.
  2. Step 2: Identify the command that redirects both outputs to /dev/null

    command > /dev/null 2>&1 sends stdout to /dev/null and then redirects stderr to the same place.
  3. Final Answer:

    command > /dev/null 2>&1 -> Option C
  4. Quick Check:

    Redirect both stdout and stderr = command > /dev/null 2>&1 [OK]
Quick Trick: Use > /dev/null 2>&1 to discard all output [OK]
Common Mistakes:
  • Using only > /dev/null discards stderr
  • Using 2> /dev/null discards only stderr
  • Confusing &> with 2>&1

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes