Add a Sudo User on CentOS 6
This guide explains how to create a new user and grant them sudo privileges on a CentOS 6 system, allowing them to run administrative commands without logging in as root.
Prerequisites
- Root or sudo access to the server
- CentOS 6 installed
Steps
-
Create the new user:
sudo adduser newuser -
Set a password for the new user:
sudo passwd newuserEnter and confirm the new password when prompted.
-
Add the user to the
wheelgroup (which has sudo access on CentOS 6):sudo usermod -aG wheel newuser -
Ensure the
wheelgroup is enabled in sudoers. Open the sudoers file withvisudo:sudo visudoFind and uncomment the following line (remove the leading
#):%wheel ALL=(ALL) ALL
Verify
Switch to the new user and test sudo access:
su - newuser
sudo whoami
The output should display root, confirming sudo privileges are active.
Notes
- To log out of the root session after setup, type
exit. - On CentOS 7+, the
wheelgroup is enabled by default in sudoers.