Frequently Asked Question

What are stdin, stdout, and stderr?

Every Unix process is born with three streams already wired up by the kernel. Standard input (stdin) is the channel a program reads from, by default, the terminal keyboard. Standard output (stdout) is where it writes its ordinary results. Standard error (stderr) is where it writes diagnostic messages, warnings, and errors. Each is just an open file from the program's point of view; the difference is purely which file descriptor number identifies it.

The point of separating stdout and stderr is composability. If find printed both "found a file" and "permission denied on /root" to the same channel, you couldn't pipe its results to another program without poisoning them with error text. By keeping the two streams apart, the shell can send normal output one way and complaints another, say, results to a pipe and errors to a log file. This split is one of the quiet design decisions that makes the Unix command line as powerful as it is.

Video

Further reading and video