$
학습 Linux 안내서
ko
XP:0
퀘스트 27T-Junction
+250 XP

Splitting Output with tee

이 퀘스트를 위한 인터랙티브 터미널 시작→설치 불필요 • 브라우저에서 바로 실행

개념 및 개요

In plumbing, a T-pipe splits a single water stream into two paths. In Linux, the tee command does the exact same thing with text streams: it reads standard input and writes it simultaneously to both the screen (stdout) and one or more files. E.g.: cmd | tee output.log.

Furthermore, tee solves a classic Linux permissions pitfall: running sudo echo "config" > /etc/app.conf fails because redirection > is handled by your unprivileged shell before sudo executes. Piping to sudo tee -a /etc/app.conf (where -a appends) runs tee with superuser privileges, safely writing to protected system files.

1. Run echo "Build completed" | tee build.log to view build output while capturing it in build.log.
2. Append privileged configuration by running echo "PORT=8080" | sudo tee -a /etc/app.conf.

명령어 구문 참조

Command / SyntaxDescription
echo "Build completed" | tee build.logWrite stdout to screen and file simultaneously
echo "PORT=8080" | sudo tee -a /etc/app.confSafely append to privileged file with sudo tee -a

검증 목표

  • ○
    Write build status to build.log using tee
  • ○
    Append PORT=8080 to /etc/app.conf using sudo tee -a

퀘스트를 완료할 준비가 되셨나요? 27?