↑↓ move Enter open Esc close

Cheat sheet · 11 commands

Pipes & redirection

Every command has one input and two outputs: stdin, stdout and stderr. Redirection points them at files; pipes connect one command's output to the next one's input. This page is that whole model on one sheet.

The 3 you will use every day

Redirect output AND errors to one file

Pipe: output of cmd1 becomes input of cmd2

Run cmd2 only if cmd1 succeeded

The full sheet

  • Write output to a file (replaces contents)
  • Append output to a file
  • Redirect only errors
  • Redirect output AND errors to one file
  • Discard error messages
  • Pipe: output of cmd1 becomes input of cmd2
  • See it live and save a copyguide ›
  • The correct way to append to a root-owned fileguide ›
  • Run cmd2 only if cmd1 succeeded
  • Run cmd2 only if cmd1 failed
  • Compare the output of two commandsguide ›
Practise these for real in the interactive course, or keep every sheet, chapter and fix in one book: The Linux Command Line Handbook.