The Linux shell's real power comes from combining small tools. Each program reads text, transforms it and writes text, and redirection and pipes connect them into a pipeline. Linux+ performance-based questions often ask you to build or interpret one of these one-liners, so read them left to right and ask what each stage receives and passes on. Every process has three standard streams: stdin (standard input, file descriptor 0), stdout (standard output, 1) and stderr (standard error, 2). > redirects stdout to a file, overwriting it; >> appends; < feeds a file to stdin. 2> redirects errors, 2>/dev/null discards them, and &> or > file 2>&1 sends both output and errors to the same file. Order matters: cmd > out 2>&1 works, while cmd 2>&1 > out sends errors to the terminal. A pipe | connects one command's stdout to the next command's stdin, and tee file copies the stream to a file while passing it on. A here-document (<<EOF) feeds inline text as input.
Keep reading for free
Create a free StudyToCert account to read the rest of this lesson: 7 more sections, 6 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.