How do I edit /etc/sudoers from a script? November 29, 2022 by Tarik Old thread, but what about: echo 'foobar ALL=(ALL:ALL) ALL' | sudo EDITOR='tee -a' visudo