Skip to content

Instantly share code, notes, and snippets.

@willsheppard
Last active October 9, 2023 08:18
Show Gist options
  • Save willsheppard/f5ec8609a971e6c76f43c6a575c44d5d to your computer and use it in GitHub Desktop.
Save willsheppard/f5ec8609a971e6c76f43c6a575c44d5d to your computer and use it in GitHub Desktop.
Sudoers cheat sheet

Define text editor

$ sudo update-alternatives --config editor

Edit /etc/sudoers file

$ sudo visudo /etc/sudoers

Add a user to sudo group

$ sudo usermod -aG sudo username
or
$ sudo gpasswd -a username sudo

(but CentOS uses "wheel" group instead)

Default config for Ubuntu 22:

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

Remove login for default users:

$ usermod -s /usr/sbin/nologin username

Sources:

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