carlessanagustin
5/9/2016 - 8:34 AM

Ways of adding NOPASSWD to /etc/sudoers file

Ways of adding NOPASSWD to /etc/sudoers file

Way 1:

groupadd -r admin
usermod -a -G admin vagrant
cp /etc/sudoers /etc/sudoers.orig
sed -i -e '/Defaults\s\+env_reset/a Defaults\texempt_group=admin' /etc/sudoers
sed -i -e 's/%admin ALL=(ALL) ALL/%admin ALL=NOPASSWD:ALL/g' /etc/sudoers
visudo -cf /etc/sudoers

Way 2:

echo %vagrant ALL=NOPASSWD:ALL > /etc/sudoers.d/vagrant
chmod 0440 /etc/sudoers.d/vagrant
usermod -a -G sudo vagrant

Recover lost sudoers

pkexec visudo