Sudo

Edit Sudo Config
visudo

Sudo Config
root   ALL=(ALL)       ALL
 * 1) Allow root to run any commands anywhere

%wheel ALL=(ALL)       ALL
 * 1) Allows people in group wheel to run all commands


 * 1) Same thing without a password
 * 2) %wheel        ALL=(ALL)       NOPASSWD: ALL


 * 1) Allows members of the users group to mount and unmount the
 * 2) cdrom as root
 * 3) %users  ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom


 * 1) Allows members of the users group to shutdown this system
 * 2) %users  localhost=/sbin/shutdown -h now


 * 1) Allow user to restart apache
 * 2) minecraft  ALL=/sbin/service httpd restart

Other Examples
apache	ALL=NOPASSWD: /var/www/chpasswd

ilock	ALL=NOPASSWD: /opt/admin/lock, /opt/admin/unlock

Apache Script to Reboot Host
reboot.php: 

visudo: www-data ALL=NOPASSWD: /sbin/reboot

ref:

Sudo Voodoo
Sudo Voodoo

Usage: sudo sudo -u

List commands and privileges available to the current user: sudo -l

Edit /etc/sudoers with visudo: Username   Hosts=(Usernames or UIDs)) Commands

Example: root   ALL=(ALL) ALL %admin ALL=(ALL) ALL strike ALL=(ALL) NOPASSWD:ALL %wheel       ALL=(ALL)       ALL
 * 1) User privilege specification
 * 1) Uncomment to allow people in group wheel to run all commands

Forgot Sudo?
You can use '!!' to recall the last command (that failed) $ rm -rf /home/user1 Permission Denied! $ sudo !!

Source: Forgetting Sudo (we've all done it) | Linux Journal

sudo: sorry, you must have a tty to run sudo
If you try to run sudo in a batch program you may get this error. Simply comment out the following line in 'visudo':
 * 1) Default requiretty

keywords
sudo visudo