I am trying to automate some stuff on my server. One of them is shutting down the server via a bash script without a password.
I've tried adding:
theuser ALL=NOPASSWD: /sbin/poweroff, /sbin/reboot, /sbin/shutdown
but I cannot shutdown the machine without having to enter a password....
theuser@server:~/Share$ sudo /sbin/poweroff [sudo] password for theuser: theuser@server:~/Share$ /sbin/poweroff Failed to set wall message, ignoring: Interactive authentication required. Failed to power off system via logind: Interactive authentication required. Failed to open initctl fifo: Permission denied Failed to talk to init daemon.
Is there any other way to do this in 20.04?