クエスト 35Stream Master
+260 XP
Standard Error & /dev/null (2>, 2>&1)
このクエストの対話型ターミナルを起動する→インストール不要 • ブラウザ上で完全動作
概念と概要
In Linux, every process opens three standard I/O streams:
- File descriptor 0: stdin (Standard Input)
- File descriptor 1: stdout (Standard Output — where normal output goes)
- File descriptor 2: stderr (Standard Error — where error messages go)
When you run cmd > output.txt, only stdout is saved; error messages still appear on your screen. To redirect errors separately, specify file descriptor 2: cmd 2> errors.log. To silence noisy errors completely, redirect them to the Linux null device (black hole): cmd 2> /dev/null. To combine both stdout and stderr into one stream or file, use &> output.log or cmd > output.log 2>&1.
ミッションの手順
1. Discard permission warnings by searching root with stderr silenced:
2. Capture an error by running
3. Combine both stdout and stderr into a single log:
find / -name "*.conf" 2> /dev/null.2. Capture an error by running
cat nonexistent.txt 2> errors.log.3. Combine both stdout and stderr into a single log:
ls /etc/hosts nonexistent.txt &> all_output.log (or > all_output.log 2>&1).コマンド構文リファレンス
| Command / Syntax | Description |
|---|---|
find / -name "*.conf" 2> /dev/null | Silence stderr by redirecting to /dev/null |
cat nonexistent.txt 2> errors.log | Redirect standard error to errors.log |
ls /etc/hosts nonexistent.txt &> all_output.log | Combine stdout and stderr into all_output.log |
検証目標
- ○Run a command redirecting stderr to /dev/null (2> /dev/null)
- ○Redirect error output to errors.log (2> errors.log)
- ○Create all_output.log capturing both streams (&> or 2>&1)