Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How do I add the following to the sudoers file in RHEL5?

daemon ALL=(ALL) NOPASSWD: /usr/local/bin/php /var/www/batch.php

Thanks :)

share|improve this question
3  
Are you sure giving daemon full rights to run php as root is sensible? –  Cian Aug 31 '09 at 14:21
    
Cian: Ya, that too, I just wasn't in the mood to go there ;-) –  Kyle Brandt Aug 31 '09 at 14:27

2 Answers 2

Use the visudo command for safe editing of the sudoers file, as root or with sudo:

visudo -f /etc/sudoers

If you don't know vi, you can use whatever editor you want by setting the EDITOR environment variable (assuming $VISUAL is not set), for example as root:

export EDITOR=/bin/nano
visudo -f /etc/sudoers

Although, if you don't know vi basics, maybe you shouldn't be editing your sudoers file :-)

share|improve this answer
    
That's "sudo visudo..." –  Dennis Williamson Aug 31 '09 at 16:41
    
Dennis: "as root or with sudo:" –  Kyle Brandt Sep 1 '09 at 11:22

Literally:

sudo echo 'daemon ALL=(ALL) NOPASSWD: /usr/local/bin/php /var/www/batch.php' >> /etc/sudoers

Personally I'd recommend Kyle Brandt's solution.

[Edit] I've added sudo to the example as per Dennis Williamson's suggestion.

share|improve this answer
    
You're probably going to want a "sudo" in there somewhere. –  Dennis Williamson Aug 31 '09 at 16:40
    
Dennis: It would just be: bash -c "echo '....' >> /etc/sudoers" –  Kyle Brandt Aug 31 '09 at 17:53

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.