Quick Tip
Tame Terminal Noise: Unified Logging with `2>&1`
Challenge: When running commands or scripts, you often want to capture both standard output (stdout) and standard error (stderr) into a single log file for easier analysis. By default, these go to separate streams.
The Solution: Redirect both stderr and stdout to a single file using the `2>&1` redirection operator.
your_command &> output.log # or your_command > output.log 2>&1
Why it works: `>` redirects stdout (file descriptor 1). `2>&1` tells the shell to duplicate file descriptor 2 (stderr) to the same location as file descriptor 1 (stdout). The `&>` is a shorthand for this combined redirection.
Pro-Tip: To append to an existing log file instead of overwriting it, use `>>` and `2>>&1` (or `>> output.log 2>&1`).
Linux Tips & Tricks | © ngelinux.com | 6/5/2026
