Quick Tip
Taming Terminal Noise: Unified Logging with `2>&1`
Challenge: When running complex commands or scripts, standard output (stdout) and error output (stderr) can get interleaved, making it difficult to track or log effectively. You want to capture both streams into a single location.
The Solution: Redirect stderr to stdout using the `2>&1` construct.
your_command 2>&1 | tee output.log
Why it works: File descriptor `2` represents stderr, and `&1` represents stdout. By redirecting `2` to `1`, all error messages are sent to the same stream as standard output, which can then be piped to `tee` to be displayed on the screen and saved to a file simultaneously.
Pro-Tip: For simply redirecting both to a file without seeing them on screen, you can use: your_command > output.log 2>&1
Linux Tips & Tricks | © ngelinux.com | 5/19/2026
