Mission 1 of 5
Redirection Operators
Capture useful output and errors in separate files.
Learn stdin, stdout, stderr, overwrite, append, heredocs, and the safe black hole /dev/null.
Mental model
Understand what is happening
stdin is input, stdout is normal output, stderr is error output.
> overwrites and >> appends.
2> captures error messages.
Guided lab
Work through the mission
Overwrite and append
Demonstrates the difference between replace and append.
cd ~/linux-practice
echo 'First' > output.txt
echo 'Second' >> output.txt
cat output.txtCapture errors
Sends stderr to a file instead of the screen.
ls missing-file 2> error.log
cat error.logUse a heredoc
Creates multi-line text safely.
cat << 'EOF' > document.txt
Line 1
Line 2
Variables like $HOME are not expanded here
EOF
cat document.txtCheckpoint
Verify the mission
Standard output and errors are stored in the intended files.
Try it yourself
One step without a recipe
Create out.txt and err.txt from a command group. Send an error to /dev/null and notice it disappears.
Need a hint?
When a command spews errors you don't care about, send them to `/dev/null` with `2>`. It's Linux's junk drawer — things go in and nothing comes out. Perfect for noisy commands where only the output matters.
Explain it back
Before you move on
- What does stderr number 2 mean?
- Which redirect operator appends?