It's probably not because it was not edited by visudo, it's because it did have syntax errors. Also check the permissions. It's perfectly fine to edit /etc/sudoers
without using visudo
. visudo
is only there to guarantee exclusive access and check the syntax before committing to the actual file. Having said that, to answer your question, you can do:
VISUAL="cp /tmp/sudoers" visudo
visudo
calls your preferred editor with /etc/sudoers.tmp
, checks the syntax on the new content of the file once the editor has returned and commits to /etc/sudoers
when happy. By setting your preferred editor to cp /tmp/sudoers
, you're actually telling it to do cp /tmp/sudoers /etc/sudoers.tmp
.
(storing that sudoers
temp file in a a world writeable directory like /tmp
sounds dangerous to me)