Quick Tip
Tame Terminal Noise: Unified Logging with `2>&1`
Challenge: When running commands or scripts, you often have both standard output (stdout) and standard error (stderr) messages. If you want to capture both into a single log file or pipe them to another command, it can be cumbersome to manage them separately.
The Solution: Use the `2>&1` redirection operator to merge stderr into stdout.
command_that_produces_output > combined_log.txt 2>&1
Why it works: The `>` redirects stdout (file descriptor 1) to `combined_log.txt`. Then, `2>&1` tells the shell to redirect file descriptor 2 (stderr) to the same place file descriptor 1 is currently going (which is `combined_log.txt`).
Pro-Tip: You can also use `&>` as a shorthand for `> … 2>&1` in many modern shells like Bash 4+ and Zsh.
Linux Tips & Tricks | © ngelinux.com | 6/8/2026
