Linux Labs

First steps / Stage 11 of 15

Where a command's output goes

Not running Starting usually ~20 s
Leave the lesson

Step 6 of 6 · summary · 2 min

Summary

  • A command prints its result to stream 1 and its error messages to stream 2; the terminal shows both interleaved.
  • > and >> redirect stream 1, 2> and 2>> stream 2. A single sign wipes the file before the command starts; a double one appends to the end.
  • Both streams in one file is > file 2>&1, and the order matters. An unwanted stream goes to /dev/null once you know what is in it.
  • At the start of the lesson the access refusals went to stream 2, and > took only stream 1 into the file — that is why the messages stayed on the screen.
Ubuntu 24.04
Loading…