Query tee linux is operators wanting visible output and a log file. See also tee command basics and cron wrappers.
Proxmox admins: log installs beside apt troubleshooting.
Stdout and file
Default overwrites; -a appends for nightly jobs.
bashtee
./deploy.sh 2>&1 | tee -a deploy-$(date +%F).log

Sudo writes
Pipe to sudo tee when editing protected files from heredocs.
bashsudo
grep -v '^#' /etc/ssh/sshd_config | sudo tee /tmp/sshd.clean

Exit code caveat
Pipeline status follows the last command — use set -o pipefail.
bashpipefail
set -o pipefail
false | tee /tmp/out; echo exit=$?

With systemd
Prefer journal for services; tee for one-off maintenance scripts.
TipRotate large tee logs with
logrotate or compress with gzip.
Quick Reference
cmd | tee file- Append:
tee -a - Enable
set -o pipefailin scripts
Related tutorials
Diagrams are original illustrations by Gnome IT Solutions. Tutorial text © Gnome IT Solutions.