I have Ubuntu 18.04.1 LTS and trying to execute "poweroff" as a sudoer but without needing to enter the password.
I added this line to visudo:
nurp ALL = NOPASSWD: /sbin/poweroff
It gives this error:
nurp@nurp-OptiPlex-7040:~$ poweroff
Failed to set wall message, ignoring: Interactive authentication required.
Failed to power off system via logind: Interactive authentication required.
Failed to open /dev/initctl: Permission denied
Failed to talk to init daemon.
I tried sudo poweroff -f
but then it asks for password.
I just want to run a long script and poweroff after it finishes. I don't want to type password on the command line.
poweroff
-command. – mook765 Dec 14 '18 at 08:27sudo chmod a+s /sbin/poweroff
– ptetteh227 Dec 14 '18 at 10:28poweroff
at a console vs. via SSH: See https://askubuntu.com/a/1005914/19626. While a different question, it's the same answer. – user535733 Dec 14 '18 at 13:04