Configuring sudo Access for Users
Learn about configuring sudo access for users.
About Configuring sudo Access
Learn about configuring sudo access.
The sudo command enables trusted users to have administrative access to systems without having to log in using root user passwords.
When users have sudo access, they can precede an administrative command with sudo, and then be prompted to enter their password. After authentication is complete, and assuming that the command is permitted, the command is processed as if it had been run by the root user.
Configuring sudo Access for Users
Learn about configuring sudo access for users.
You need root privileges to configure sudo access for users.
-
Log in to the system as the
rootuser. -
Create a new user account using the
useraddcommand with the-G supportoption. This ensures the new user is added to thesupportgroup, granting them SSH access to the appliance.For example, to create a normal user account for the user
psmith:# useradd -G support psmith -
Set a password for the user using the
passwdcommand.For example:
# passwd psmith Changing password for user psmith. New password: <new_password> Retype new password: <new_password> passwd: all authentication tokens updated successfully -
Run the
visudoutility to edit the/etc/sudoersfile.# visudoThe
sudoersfile defines the policies that thesudocommand applies. -
Find the lines in the
sudoersfile that grant access to users in the wheel group when enabled.## Allows people in group wheel to run all commands # %wheel ALL=(ALL) ALL -
Remove the comment character (
#) at the start of the second line, which begins with%wheel.This enables the configuration option.
-
Save your changes and exit the editor.
-
Add the user account that you created earlier to the
wheelgroup using theusermodcommand.For example:
usermod -aG wheel psmith -
Test that the updated configuration enables the user that you created to run commands using
sudo.-
Use the
sucommand to switch to the new user account that you created.# su psmith -
Use the
groupscommand to verify that the user is in the wheel group.$ groups psmith wheel -
Use the
sudocommand to run thewhoamicommand.Because this is the first time that you have run a command using
sudofrom this user account, the banner message is displayed. You will be prompted to enter the password for the user account.$ sudo whoamiThe following output should appear:
We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility.Enter the password when prompted:
[sudo] password for psmith: <password> rootThe last line of the output is the user name that is returned by the
whoamicommand. Ifsudoaccess has been configured correctly, then this value isroot.
-