Skip to content

Instantly share code, notes, and snippets.

@ju1ius
Created July 26, 2011 13:51
Show Gist options
  • Save ju1ius/1106811 to your computer and use it in GitHub Desktop.
Save ju1ius/1106811 to your computer and use it in GitHub Desktop.
Allow all physical users to shutdown and reboot without password
#! /bin/bash
USERS=($(cat /etc/passwd | grep /home/ | grep -v /bin/false | cut -d : -f 1))
ALIAS=$(printf ",%s" "${USERS[@]}")
PATTERN="$ a\
${ALIAS:1} ALL=\(ALL\) NOPASSWD: /sbin/shutdown, /sbin/reboot
"
# Edit /etc/sudoers to allow all physical users to shutdown and reboot without password
# Your previous sudoers file will be backed as /etc/sudoers.bak
sudo sed -i.bak -e "$PATTERN" /etc/sudoers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment