Chapter 8. Granting sudo access to a user
System administrators can grant sudo
access to allow non-root users to execute administrative commands. The sudo
command provides users with administrative access without using the password of the root
user.
When users need to perform an administrative command, they can precede that command with sudo
. The command is then executed as if they were the root
user.
Be aware of the following limitations:
-
Only users listed in the
/etc/sudoers
configuration file can use thesudo
command. -
The command is executed in the shell of the user, not in the
root
shell.
Prerequisites
-
Root
access
Procedure
Open the
/etc/sudoers
file.# visudo
The
/etc/sudoers
file defines the policies applied by thesudo
command.In the
/etc/sudoers
file find the lines that grantsudo
access to users in the administrativewheel
group.## Allows people in group wheel to run all commands %wheel ALL=(ALL) ALL
-
Make sure the line that starts with
%wheel
does not have#
comment character before it. - Save any changes, and exit the editor.
Add users you want to grant
sudo
access to into the administrativewheel
group .# usermod --append -G wheel username
Replace username with the name of the user.
Example 8.1. Adding a user to the wheel group
To add the user
sarah
to the administrativewheel
group, use:# usermod --append -G wheel sarah
Verification steps
To verify the user is added to the administrative
wheel
group, use theid
utility.# id sarah
The output returns:
uid=5000(sarah) gid=5000(sarah) groups=5000(sarah),10(wheel)