With Sudo you can provide special privileges to any user or group. In Linux, there are few commands which can be accessible with root user only. You can authorize the required user who can run those commands with sudo. Reboot command can be run only by root user or sudo user.
Following are the steps to enable passwordless sudo for User.
- Login to your Linux server with root user using ssh.
- Let us create a user. Here, we will create test user.
# adduser test
- Set Password for user test.
New password: Retype new password: passwd: all authentication tokens updated successfully.
Add Users to Sudo Group
In Centos, there will be a group named "wheel". All the user accounts added to this group will have sudo privileges automatically. We can add our user in wheel group. This is the easiest and quick solution to provide sudo privilege.
- Let us check if wheel group is enabled on server.
- Type below command to open the configuration file.
# sudo visudo
- You need to uncomment the %wheel line by removing # sign as per the below screen capture to enable wheel group. (If the %wheel is not commented, keep it as it is).
# Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL
- Add user test to wheel group.
# usermod -aG wheel test
- To verify the new user with sudo privileges, login with the test user and run the below command.
# sudo whoami
It should provide the below output if user is added with sudo privilege, it will provide the below output.
This is how you can provide sudo privilege to any of the users in Centos.
Facing an issue with su user? Please refer to SU > Enable Cagefsctl for more details.