In Linux or Unix-based operating systems, there are two types of users: a super-user (root) and an average or regular user. The root user has complete control of the operating system, and it has privileges to run administrative commands like installing, removing, and updating software packages, changing permissions, and configuring different services. The non-root users have limited interactions with an operating system environment, and they can perform only user-specific tasks.

The sudo command, short for “super-user do,” is a Linux utility that allows an average user to run any commands with unlimited privileges. In this case, you must add an average user to the sudo Group to execute administrative commands.

In this post, we will show you how to create a sudo user in Rocky Linux. This procedure is compatible with Rocky Linux 8 and Rocky Linux 9.

Create a Normal User in Rocky Linux

If you have not created any normal or no-root user on your system, you will need to create one user.

Let’s create a new user named user1 with the following command:

adduser user1

Next, set a password for this user with the following command:

passwd user1

You will be asked to set a password as shown below:

Changing password for user user1.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

Also Read

How to Change or Set User Passwords in Linux

Enable Wheel Group access for All Users

Next, you must edit /etc/sudoers file and confirm that the wheel group is enabled.

nano /etc/sudoers

Make sure the following line exists:

%wheel ALL=(ALL) ALL

Save and close the file after the confirmation.

Add a Normal User to the sudo (wheel) Group.

Next, you must add your created user to the sudo (wheel) Group to grant it administrative privileges.

You can use the usermod command to add a regular user to the wheel group.

usermod -aG wheel user1

This command will add a user1 to the wheel group.

Verify the Sudo User

After adding a normal user to the sudo Group, you must verify whether the newly created user has sudo rights.

To verify, switch the user to the user1 using the following command:

su - user1

Next, run any administrative command with sudo:

sudo dnf update

If everything is fine, you will be asked to provide a password for user1:

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.

[sudo] password for user1: 

Provide the password of user1 to run the above command.

The above output confirms that the user has sudo rights and can run administrative commands.

Also Read

How to Use the id Command in Linux

Conclusion

In this post, we explained how to create a sudo user in Rocky Linux 8. You can now grant super-user privileges to any regular user in your Linux environment. Try it on VPS hosting from Atlantic.Net!