Why when I run I get the error:
$ sudo echo "127.0.0.1 db-local.internal" >> /etc/hosts
bash: /etc/hosts: Permission denied
But when I do sudo su
I can edit this file without any problem.
UPD
Because question is closed I add answer here:
sudo bash -c "echo 'some string' >> test.txt"
sudo
rights. The problem here occurs because the shell redirect happens in the user's security context, not sudo context. The user themselves doesn't have rights to edit the file /etc/hosts.