Quick Tip
Redirect stderr to stdout for Unified Logging
Challenge: When troubleshooting or monitoring processes, you often need to see both standard output (stdout) and standard error (stderr) messages in a single, cohesive log. Separated streams can make it difficult to follow the sequence of events.
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: File descriptor 1 represents stdout, and file descriptor 2 represents stderr. `2>&1` tells the shell to redirect file descriptor 2 (stderr) to the current location of file descriptor 1 (stdout).
Pro-Tip: The `&>` redirection is a shorthand for `2>&1` and is often more convenient for combining both streams into a single file.
Linux Tips & Tricks | © ngelinux.com | 5/20/2026
