zsh=/bin/zsh
sh -c "echo $zsh >> /etc/shells"
sh: /etc/shells: Permission denied
OK, fine. And if I add sudo
, it works. Fine.
zsh=/bin/zsh
sudo sh -c "echo $zsh >> /etc/shells"
But if I use open
(to add /bin/zsh
in /etc/shells
manually), then even though I already use sudo
, trying to edit the file brings up a dialog window that says that I cannot edit it:
sudo sh -c 'open /etc/shells'
You don’t own the file “shells” and don’t have permission to write to it.
You can duplicate this document and edit the duplicate. Only the duplicate will include your changes.
Why is that? What is wrong with the sudo sh -c 'open /etc/shells'
command?