Skip to content

Instantly share code, notes, and snippets.

@marianposaceanu
Last active December 27, 2015 12:48
Show Gist options
  • Select an option

  • Save marianposaceanu/7328062 to your computer and use it in GitHub Desktop.

Select an option

Save marianposaceanu/7328062 to your computer and use it in GitHub Desktop.
Simple way to run stuff like `sudo shutdown` without entering a password

Run sudo commands without entering a password

Simple way to run stuff like sudo shutdown without entering a password.

Tip: do not use this in production, I use it to shutdown my VMs when I'm done working

  1. run: sudo EDITOR=vim visudo
  2. add a new group, let's say named noners : %noners ALL=(ALL) ALL
  3. run: sudo vim /etc/sudoers.d/g_noners
  4. let's say the user you want to run sudo without password is marian then just add:
%newgroup ALL=(ALL) ALL  
marian ALL=(ALL) NOPASSWD: /sbin/shutdown  
marian ALL=(ALL) NOPASSWD: /sbin/reboot  
marian ALL=(ALL) NOPASSWD: /usr/bin/pacman
  1. all done.

credits:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment