When you run sudo with a command, only the command and parameters are privileged. A pipe transfers data from one command to another command, e.g. |
, <
or >
.
Works:
print 'root' | sudo tee /etc/config
sudo sh -c 'echo "root" >/etc/config'
When you run sudo with a command, only the command and parameters are privileged. A pipe transfers data from one command to another command, e.g. |
, <
or >
.
Works:
print 'root' | sudo tee /etc/config
sudo sh -c 'echo "root" >/etc/config'