How to allow non-super users to shutdown computer in Linux

Standard permissions do not allow regular users to shutdown a unix machine. Often it is useful to grant non-super users the ability to shutdown the server. there are a number of ways to do this. This is one.

=Requirements=
 * Access to the root account

=Method 1 (recommended)= This method uses sudo to allow a user to run shutdown as root.


 * 1) Login as root
 * 2) Add user to group, wheel, in /etc/group
 * 3) nonsense deleted, never change permissions of /etc/sudoers"
 * 4) Edit /etc/sudoers using "sudo visudo"
 * 5) * Add line:
 * %wheel ALL= NOPASSWD: /sbin/shutdown
 * 1) nonsense deleted


 * Any user in group wheel, can shutdown computer by executing:
 * sudo /sbin/shutdown ...


 * Optional:
 * Add an alias for shutdown to have sudo
 * alias shutdown='sudo /sbin/shutdown' 

=Method 2=
 * 1) Login or switch users to root
 * you can switch users to root by typing su at a command prompt.
 * 1) Edit /etc/groups
 * 2) * add a line for group shutdown and add your user name to it
 * 3) * Example: shutdown:x:510:yourUserName
 * 4) * Execute: groups to display you group membership
 * 5) Change ownership of /sbin/shutdown giving access to group shutdown
 * 6) * Execute: chown root:shutdown /sbin/shutdown
 * 7) * ls -l /sbin/shutdown should display similar to the following
 * ... root shutdown 19K Jan 23 10:50 /sbin/shutdown
 * 1) Change permissions to allow the shutdown group read and execute permission.
 * 2) * Execute: chmod 750 /sbin/shutdown
 * 3) * ls -l /sbin/shutdown should display similar to the following
 * -rwxr-x--- 1 root shutdown 19K Jan 23 10:50 /sbin/shutdown
 * 1) shutdown can only be run by root so you need to have group shutdown execute the program as if you were root.
 * 2) * Execute chmod u+s /sbin/shutdown
 * 3) * ls -l /sbin/shutdown should display similar to the following
 * -rwsr-x--- 1 root shutdown 19K Jan 23 10:50 /sbin/shutdown
 * 1) To test execute: shutdown -k now and shutdown will pretend to shutdown.
 * 2) To shutdown, execute shutdown -h now. For Details on this command, execute shutdown --help

Common Errors

 * bash: /sbin/shutdown: Permission denied
 * This means that shutdown does not allow your user or group to execute the file. try ls -l /sbin/shutdown, see howto change file permissions
 * shutdown: you must be root to do that!
 * shutdown will not 'shutdown' without being root is some form of 'sudo' or 'chmod +s'
 * /etc/shutdown.allow, seems to only be used in inittab, and shutdown -a now does not work from terminal.

From HowTo Wiki, a Wikia wiki.