I'm running Linux Mint 17.3.

By default, running shutdown or other commands like reboot, poweroff requires root privilege.

So I added the following line

lesaff_b ALL=(ALL) NOPASSWD: /sbin/poweroff, /sbin/reboot, /sbin/shutdown

to /etc/sudoers. I know it still requires that I run these commands as sudo but it won't ask for password, so I create an alias for each of them.

It worked fine the first time, but then it stopped working, I now need to run these commands as sudo and type my password. I know there are others ways of running these commands without sudo, but why doesn't it work whereas it should, and most importantly, why did it work one time ??

  • I typed "alias shutdown='sudo shutdown'" and so on for each of the command. But I deleted the aliases to see if it changes anything and it does not. Commented Jan 30, 2016 at 1:38
  • I added those command aliases to ~/.bash_aliases Commented Jan 30, 2016 at 1:42
  • Yes exactly, "shutdown is aliased to `sudo shutdown'" Commented Jan 30, 2016 at 1:47
  • No it still asks for password :/ Commented Jan 30, 2016 at 1:53
  • do you happen to have any entries in the sudoers file after the given line? sudoers works its way up the file, so if you also have a line like "lesaff_b ALL=(ALL) ALL" (for example) that would "catch" the shutdown program, sudo will follow that later rule and dutifully prompt you.
    – Jeff Schaller
    Commented Jan 30, 2016 at 2:27

1 Answer 1


Given the information we learned in the comments, it appears that:

  1. you ran some command with sudo (perhaps to edit sudoers to add the quoted NOPASSWD line in the Q)
  2. sudo cached those credentials, allowing you to run a reboot or shutdown within timestamp_timeout (5 minutes by default, I believe)
  3. but after the reboot (more than timestamp_timeout), you were again prompted for a password for those commands because there was a pre-existing ALL:ALL sudo rule without the NOPASSWD flag -- that you didn't add but were caught up in. Because sudo uses the last matching rule, it prompted you unexpectedly.

The solution here is to move your rule below the pre-existing ALL:ALL rule (or, if you like, add the NOPASSWD flag to the existing ALL:ALL rule).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .