Open up a terminal (CTRL + T)
and type the following
Add the following line:
%group_name ALL=(ALL) NOPASSWD: /sbin/poweroff, /sbin/reboot, /sbin/shutdown
user_name ALL=(ALL) NOPASSWD: /sbin/poweroff, /sbin/reboot, /sbin/shutdown
This allows the user/group to run the above three commands, using sudo, however with no password.
sudo poweroff will now result in a passwordless shutdown.
However, to make this even cleaner, we'll add an alias, so that running
sudo shutdown now.
~/.bash_aliases for editing.
Insert the following line at the end of the file:
alias shutdown='sudo shutdown now'
Finally, load the changes to the
Try it out!