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

Sept. 11, 2012, 9:24 a.m.Janos


  • 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.