12

I have an /etc/sudoers with the following:

glens   ALL=NOPASSWD:/usr/sbin/service php5-fpm
glens   ALL=(ALL:ALL) ALL

And I'm trying to run the command:

sudo /usr/sbin/service php5-fpm restart

However, I'm still prompted for my password.

This AskUbuntu question/answer suggests I have the correct syntax, but I'm still prompted.

1 Answers1

22

The NOPASSWD entry should be placed beneath the other line:

glens   ALL=(ALL:ALL) ALL    
glens   ALL=NOPASSWD:/usr/sbin/service php5-fpm

From the manual (man sudoers):

When multiple entries match for a user, they are applied in order. Where there are multiple matches, the last match is used (which is not necessarily the most specific match).

Therefore your order of NOPASSWD being first will be overridden by the second line (ALL=(ALL:ALL) ALL).

Lambert
  • 12,680