This is the shell command that results in "Permission denied" when I'm trying to append the data in a file to another file with sudo:
sudo cat add_file >> /etc/file
The file at /etc/file
is owned by root
(i.e. me) and its permissions are rw-r--r--
. Should I become root
for a moment to make it work or is there a workaround for sudo
?
Run bash
as sudo
:
$ sudo bash -c "cat add_file >> /etc/file"
$ whoami;sudo bash -c "whoami";whoami
iiSeymour
root
iiSeymour