ES
Linux / Unix Fundamentals

Standard Streams

System Channels (File Descriptors)

0 stdin
PID: 4824
PROCESS
1 stdout
2 stderr

Why use 2>&1?

# Redirect errors to normal output

command > out.log 2>&1

By default, errors (2) go through a different channel than data (1). With 2>&1 you "merge" channel 2 into channel 1 to save everything in a single file.

Input (0)

Data source. Keyboard, files, or pipes (|).

Output (1)

Normal program results (Standard Output).

Error (2)

Diagnostic messages and failures (Standard Error).

Descriptors

In Unix, "everything is a file", including these streams.

logo xeland314
0 IN1 OUT2 ERR