sudo for new user with privileges on Rocky Linux 8

An introduction serves as an initial glimpse into the topic at hand.

The sudo command allows regular users to have administrator privileges, which are typically reserved for the root user. This tutorial demonstrates how to create a new user with sudo access on Rocky Linux 8 without making changes to the /etc/sudoers file of your server.


Please skip to step 3 if you wish to set up sudo for an already existing Rocky Linux user.

To get started, access your server by logging in.

Log in to your server as the root user using SSH.

  1. ssh root@your_server_ip_address


Instead of entering “your_server_ip_address” in the above field, substitute it with the IP address or hostname of your server.

Step 2 — Enrolling a New User into the System

To include a new user in your system, employ the adduser command.

  1. adduser sammy


Make sure to replace “sammy” with the desired username for creation.

To update the password of the new user, employ the passwd command.

  1. passwd sammy


Make sure to substitute “sammy” with the newly created user. You will be asked twice to provide a new password.


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

Step 3 involves including the user in the wheel group.

Add the user to the wheel group by utilizing the usermod command.

  1. usermod -aG wheel sammy


Make sure to replace “sammy” with the desired username for granting sudo privileges. The wheel group members have complete sudo access by default on Rocky Linux.

Step 4— The Testing of sudo Privileges

To confirm that the newly assigned sudo privileges are functioning correctly, begin by employing the su command to transition from the root user to the recently established user profile.

  1. susammy


To confirm your access to sudo as a new user, simply add the word sudo before the command you intend to execute with superuser privileges.

  1. sudo command_to_run


One option for paraphrasing the statement could be:

You have the option to display the items present in the /root folder, which typically can only be accessed by the root user.

  1. sudo ls -la /root


When you use sudo for the first time in a session, you will be asked to enter the password for that user’s account. Please provide the password to continue.


[sudo] password for sammy:


Please be aware that this is not a request for the root password. Kindly provide the password of the user with sudo privilege, not the root password.

If your user is in the appropriate group and you have correctly entered the password, the command executed with sudo will have root privileges.

In summary, to wrap up, in conclusion.

You have successfully followed this quickstart guide where you formed a new user account and included it in the wheel group to allow sudo access. If you seek more comprehensive instructions on configuring a Rocky Linux 8 server, we recommend referring to our tutorial titled “Initial Server Setup with Rocky Linux 8”.


more tutorials

permissions in PostgreSQL(Opens in a new browser tab)

Python 3 installing on Rocky Linux 9(Opens in a new browser tab)

How can I include new entries in a Python dictionary?(Opens in a new browser tab)

ValueError exception in Python code examples(Opens in a new browser tab)

Leave a Reply 0

Your email address will not be published. Required fields are marked *