-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linux tee Guide
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to tee on Linux, covering Arch Linux, CachyOS, and other distributions including duplicating output, logging, and output redirection.
tee duplicates output to files and stdout.
Uses:
- Duplicate output: Send to file and screen
- Logging: Save output while viewing
- Pipeline tool: Split output streams
- Debugging: Save output for analysis
Why it matters:
- Logging: Save output while viewing
- Debugging: Capture output
- Monitoring: Watch and log simultaneously
Simple example:
# Save to file and display
ls -l | tee output.txt
# Shows on screen and saves to fileAppend to file:
# Append mode
ls -l | tee -a output.txt
# -a = append (doesn't overwrite)Save to multiple:
# Multiple files
ls -l | tee file1.txt file2.txt
# Saves to both filesSave with sudo:
# Save to protected file
ls -l | sudo tee /root/output.txt
# tee needs sudo, not lsLog commands:
# Log command output
command | tee log.txt
# View and saveIn scripts:
#!/bin/bash
{
echo "Starting script"
# commands here
} | tee script.logCheck installation:
# Check tee
which tee
# Usually in coreutils
# Install if missing
sudo pacman -S coreutilsThis guide covered tee usage, output duplication, and logging for Arch Linux, CachyOS, and other distributions.
- echo Guide - Text output
- Bash Scripting Guide - Scripting
-
tee Documentation:
man tee
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.