You can use this snippet to avoid it:
sed -i "/^%admin/ {/NOPASSWD/! s/ALL$/NOPASSWD:ALL/}" /etc/sudoers
sed -i "/^%sudo/ {/NOPASSWD/! s/ALL$/NOPASSWD:ALL/}" /etc/sudoers
Here is how to read it:
* find only strings that start with %admin
* skip them if they already contain NOPASSWD
(so you can safely run this script many times)
* substitute last(on the line) matching of word "ALL" with NOPASSWD:ALL
No comments:
Post a Comment