Skip to content

Instantly share code, notes, and snippets.

@angelikatyborska
Created March 1, 2019 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelikatyborska/b22fd3ac81a8bf63873d810cb672637b to your computer and use it in GitHub Desktop.
Save angelikatyborska/b22fd3ac81a8bf63873d810cb672637b to your computer and use it in GitHub Desktop.
Append to a 644 root owned file
# as sudoer, non-root:
echo 'foo' | sudo tee -a /etc/hosts
# or
sudo bash -c "echo 'foo' >> /etc/hosts"
# this does NOT work
sudo echo 'foo' >> /etc/hosts
@angelikatyborska
Copy link
Author

This can be useful in a non-interactive shell like in a CI job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment