Create A New User With Sudo Rights In Linux

By Chandrashekhar Fakirpure

Updated on Feb 02, 2024

In this tutorial, we will explain you how to create a new user with sudo rights in AlmaLinux.

Sudo command is one of the most important command. It stands for “super user do!”. Running the sudo command is much better than logging in as the root user.

Any command that has the "sudo" prefix will run with privileged access, or in other words, allow a user with the necessary permissions to execute a command in the role of another user, such as the superuser.

1. Loggin Into The Server

Loggin into your server with Root user access.

ssh root@server_ip_address

2. Add User

User following command to add a new user.

adduser [new_user]

Note: Replace [new_user] with your desire username.

Use following command to update the new user's password.

pass [new_user]


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

3. Add User In The Wheel Group

Use following usermod command to modify new user's group and add the server in the Wheel group.

usermod -aG wheel [new_user]

Note: Replace [new_user] with the newly created username.

4. Test The Access

At this point we have successfully created user and added the user in the Wheel group.

Switch from root user to new user account.

su -  [new_user]

Note: Replace [new_user] with the newly created username.

Let's run update command that root user has privilege to run it.

sudo dnf update -f

When you run sudo command first time in one session, it will ask you to enter user account password. Enter the password to proceed./p>

[sudo] password for [new_user]

If the command runs successfully, the new user has root privilages.

In this tutorial, we have seen how to create a new user with sudo rights in AlmaLinux.