Add User to Sudoers in CentOS

The sudo command stands for “Super User DO” and temporarily elevates the privileges of a regular user for administrative tasks.

Step 1: Verify the Wheel Group is Enabled

Your CentOS 7 installation may or may not have the wheel group enabled.

Open the configuration file by entering the command:

# visudo

Scroll through the configuration file until you see the following entry:

## Allows people in group wheel to run all commands
# %wheel        ALL=(ALL)       ALL

If the second line begins with the # sign, it has been disabled and marked as a comment. Just delete the # sign at the beginning of the second line.

Step 2: Add User to Group

To add a user to the wheel group, use the command:

# usermod –aG wheel <username>

Step: 3 Switch to the Sudo User

Switch to the new (or newly-elevated) user account with the su (substitute user) command:

su - <username>