Introduction
Sudo command allows you to run a command as root/administration – usually it grants the root user privileges to normal users. This guide/tutorial will show you how to create a new user with sudo access on Rocky Linux 8
Adding a New User to the Server
First, open the terminal or SSH client like putty and SSH in to your server using the root user
Add the new user using the following command
adduser teckassist
Note: Make sure to replace tecassist
with the actual username you want to create.
Update the password of the new user, using the following command
passwd teckassist
Note: Remember to replace teckassist
with the actual user that you just created. You will have to enter the password twice:
Changing password for user teckassist. New password: Retype new password: passwd: all authentication tokens updated successfully.
Adding the User to the wheel Group
By default, on Rocky Linux, all members of the wheel group have full sudo access.
add the user to the wheel group using the following command
usermod -aG wheel teckassist
Note: Make sure to replace teckassist
with the actual username you’d like to give sudo privileges to.
Verifying sudo
Access
First, change the newly created user using the following command
su - teckassist
So now, to verify the sudo access is working or not, run any command along with before sudo
sudo cd /home
Note: It will ask the password for the first time, Enter the password of the newly created user.
If it works, it will change the directory to home directory.
Conclusion
In this tutorial, we have created a new user and enable the sudo access to the user.