Pipe to a file using sudo The tee -a command will append changes to a file (just like to >>). The -a flag stands for "append". echo "some text" | sudo tee -a write-protected.txt