Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've been trying to grant www-data to use sudo service apache2 restart without a password but no matter what I try, nothing works. I have read a few hundred posts regarding this issue on different forums but nothing in them helps.

I know that the permissions are added in order, so the specific command should go at the end of the list. Here is my file:

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification


# User privilege specification
root    ALL=(ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL) ALL

# See sudoers(5) for more information on "#include" directives:

# includedir /etc/sudoers.d

%www-data ALL=(ALL) NOPASSWD: /usr/sbin/service apache2 restart

From what I gather, anyone in www-data should now be able to run sudo service apache2 restart and not require a password. It still asks for a password. I have tried to add:

%www-data ALL=(ALL) NOPASSWD: ALL

And that works as expected. I can give them no password for all commands but not for one. Of course that would be really bad idea.

Any help would be appreciated. This is the latest version of Ubuntu

share|improve this question
    
Turns out I had sudo aliased in my .zshrc. Removing the alias fixed the issue. Now it works as it should. This link was useful: askubuntu.com/questions/183093/sudo-arguments-not-working –  Deshiknaves May 5 '13 at 11:58
    
Can't post an answer for a few hours. –  Deshiknaves May 5 '13 at 11:58

1 Answer 1

Turns out I had sudo aliased in my .zshrc. Removing the alias fixed the issue. Now it works as it should.

This link was useful: Sudo arguments not working

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.