Quick Tip
Taming Terminal Noise: Unified Logging with `2>&1`
Challenge: When running commands that produce both standard output (stdout) and standard error (stderr), it can be difficult to track or log all output cohesively. You might want to capture both in a single file for analysis.
The Solution: Redirect both stdout and stderr to a single destination using the `2>&1` construct.
your_command 2>&1 | tee output.log
Why it works: File descriptor `1` represents stdout and `2` represents stderr. `2>&1` tells the shell to redirect file descriptor 2 (stderr) to wherever file descriptor 1 (stdout) is currently going. Piping this combined output to tee allows you to see it on the terminal while also saving it to output.log.
Pro-Tip: For simple redirection to a file without seeing it on the terminal, you can use your_command &> output.log or your_command > output.log 2>&1.
Linux Tips & Tricks | © ngelinux.com | 6/1/2026
