Redirect `stderr` to `stdout` for Unified Logging
Quick Tip
Redirect `stderr` to `stdout` for Unified Logging
Challenge: When troubleshooting or monitoring scripts, you often have both standard output (stdout) and standard error (stderr) streams that you want to capture or view simultaneously.
The Solution: Use the `2>&1` redirection operator to send standard error to the same destination as standard output.
your_command &> output.log # or your_command > output.log 2>&1
Why it works: In Linux, file descriptor `1` represents stdout and file descriptor `2` represents stderr. The `2>&1` tells the shell to redirect file descriptor 2 to the current location of file descriptor 1. The `&>` is a shorthand for this operation.
Pro-Tip: Use `| tee output.log` instead of `&> output.log` if you want to see the output on your terminal *and* save it to a file simultaneously.
Linux Tips & Tricks | © ngelinux.com | 5/9/2026
