I'm using Amazon Linux. I'm trying to append some text onto a file. The file is owned by root. I thought by using "sudo", I could append the needed text, but I'm getting "permission denied", see below
[myuser@mymachine ~]$ ls -al /etc/yum.repos.d/google-chrome.repo
-rw-r--r-- 1 root root 186 Jul 31 15:50 /etc/yum.repos.d/google-chrome.repo
[myuser@mymachine ~]$ sudo echo -e "[google-chrome]\nname=google-chrome\nbaseurl=http://dl.google.com/linux/chrome/rpm/stable/\$basearch\nenabled=1\ngpgcheck=1\ngpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub" >> /etc/yum.repos.d/google-chrome.repo
-bash: /etc/yum.repos.d/google-chrome.repo: Permission denied
How can I adjust my statement so that I can append the necessary text onto the file?
bash -c
example in their answer (which pretty much does the same thing assu -c
) so this one is really completely unnecessary. – MD XF Aug 01 '17 at 02:59sudo $SHELL -c '...'
. Furthermore, the other answer doesn't useecho
s escape option (not that the OP would miss that). That said, this whole question doesn't add anything. Hence, I flagged it as a duplicate. – rlf Aug 01 '17 at 13:26