Using Groups to Manage sudo Access
Assign sudo permissions to groups and add users as group members.
Instead of specifying different levels of sudo access for each
individual user you can optionally manage sudo access at group level by
adding the % symbol to the group name.
For example, to define permissions for an existing group called example
in the /etc/sudoers.d/ directory and then add the user
alice to that group:
-
Create the
/etc/sudoers.d/examplefile by using thevisudocommand:sudo visudo /etc/sudoers.d/example -
Grant the
examplegroup permissions to manage system services and software packages:%example ALL= SERVICES, SOFTWARE -
Add the the
aliceuser to theexamplegroup:sudo usermod -aG example alice
Or, you can set group permissions directly in the /etc/sudoers file. For
example, to grant the user bob full sudo access on all
hosts, enable the existing group wheel, and then add the user
bob to it:
-
Open the
/etc/sudoersfile by using thevisudocommand without specifying a target file:sudo visudo -
Remove the comment
#symbol from the beginning of the following line in the/etc/sudoersfile:%wheel ALL=(ALL) ALL -
Add the
bobuser to thewheelgroup to grant them fullsudoaccess on all hosts:sudo usermod -aG wheel bob