Sudoer without password
July 17, 2021 | StackThere may be occations where some tasks, that usually requires root privileges, would be more handy to run without the need to provide a password.
In this example it is an automation for update, upgrade and reboot. Ofcause it is not advisable to run all sudo commands without providing passwords, in particular not on a webserver.
Due to the importance of the sudoer config file, it is advised to use the "visudo" editor:
sudo visudo
NOT ADVISED. If you just want your sudo user to run all commands without the need to provide passwords, add the following line:
your_user_name ALL=(ALL) NOPASSWD:ALL
If you want to restrict this abillity, to ex. update/upgrade/reboot (it would still be very problematic if a script were set to reboot you machine every second, so you might just use update, upgrade only)
your_user_name ALL=(ALL) NOPASSWD:/usr/bin/apt update, /usr/bin/apt upgrade, /sbin/reboot
This will remove the need for passwords for these commands.