0

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.

marked as duplicate by muru, karel, Eric Carvalho, Charles Green, Zanna Dec 14 '18 at 20:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    have you tried all alternatives here ? ubuntuforums.org/showthread.php?t=963124 – John Joe Dec 14 '18 at 8:10
  • Interesting because your line looks correct, and I replace nurp with alvin it works here. – Alvin Liang Dec 14 '18 at 8:11
  • This is the correct syntax - maybe you have some other error in your sudores file? you can check as root with 'visudo -c' – Robert Riedl Dec 14 '18 at 8:26
  • I don't need root privileges to use the poweroff-command. – mook765 Dec 14 '18 at 8:27
  • 1
    There's a difference between running poweroff at a console vs. via SSH: See askubuntu.com/a/1005914/19626. While a different question, it's the same answer. – user535733 Dec 14 '18 at 13:04

Browse other questions tagged or ask your own question.