1

Redirect stdout to a file you don't have write permission on

echo hello | sudo tee -a /path/to/file

September 11, 2012bashoneliners

Explanation

  • The tee command copies standard input to standard output, making a copy in zero or more files.
  • If the -a flag is specified it appends instead of overwriting.
  • Calling tee with sudo makes it possible to write to files the current user has no permission to but root does.