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