Basic Linux Tutorial
Computer Tutorial

Standard Redirection



Standard Redirection

Most Linux / UNIX commands are designed to take simple text (alphanumeric) data and punctuation as input. Usually, the output is also of simple text.

Linux commands is opens three standard data streams

1 .   standard input ( stdin )
2 .   standard output ( stdout )
3 .   standard error ( stderr )

Every Linux command takes input data from stdin and sends its normal output to stdout and error messages to stderr. These data streams are often called standard input/output. Linux associates numbers known as file descriptors with all open files.
The bash shell has three basic streams; it takes input from stdin (stream 0), it sends output to stdout (stream 1) and it sends error messages to stderr (stream 2) .
The drawing below has a graphical interpretation of these three streams.

Input output redirection

Input output redirection

Standard input, usually the user keyboard, is normally the place where a program reads its input from. Standard output, usually your terminal screen, is where the results of a command or program are displayed. In normal cases, standard error messages are also displayed on the terminal screen, but it is always possible to separate stdout from stderr. The Linux shell can redirect any of these streams to a file, a device, or some other command, as required by the user.