Atlantic.Net Blog

How to Create a Sudo User in Rocky Linux 8

In Linux or Unix-based operating system, there are two types of users: a superuser (root) and a normal or regular user. The root user has full 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 a normal user to run any commands with unlimited privileges. In this case, you will need to add a normal user to the sudo group in order to execute administrative commands.

In this post, we will show you how to create a sudo user in Rocky Linux 8.

Prerequisites

  • A server running Rocky Linux 8 on the Atlantic.Net Cloud Platform
  • A root password configured on your server

Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing Rocky Linux 8 as an operating system with at least 1GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Create a Normal User in Rocky Linux

If you have not created any normal or no-root user on your system, then 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 will need to 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 will need to add your created user to the sudo (wheel) group in order to grant it administrative privileges.

You can use the usermod command to add a normal 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 will need to 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 superuser privileges to any regular user in your Linux environment. Try it on VPS hosting from Atlantic.Net!

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G3.2GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year