Rocky Linux 10 Tutorial / Create a user and grant or revoke wheel and sudo access

In Rocky Linux 10, the default starting point is to work with a regular account and use sudo only for commands that require administrative privileges. Adding a user to the wheel group allows administrative commands via the default sudo policy, but whether it actually applies must be checked together with the group and sudo privileges in a new login environment.

Distinguish the roles of regular users, wheel, and sudo

Users are distinguished by a number called UID (User Identifier). Groups are used to assign file access or administrative roles to multiple users and are distinguished by GID (Group Identifier). Primary groups and supplementary groups are different. The same user can belong to supplementary groups like wheel in addition to their primary group.

root is usually the system administrator account with UID 0. wheel is a group used by the default sudo policy to grant administrative access, and sudo is a tool to run commands allowed by policy with another user's privileges. Being in wheel does not automatically make all programs you normally run become root.

Objects to check What does it show?
whoami The username of the user currently running the command
id, id -nG The current process's user, group, and list of group names
id labops Account and group database information of the specified user
sudo -l Commands allowed by sudo policy for the current user
sudo whoami User of the command executed through sudo. In this practice, root is expected

Rocky Linux User Management Guide explains tools for managing UIDs, GIDs, accounts, and groups. Instead of directly editing /etc/passwd or /etc/group for practice, we will use useradd, usermod, and gpasswd.

First, check the access and default policies of existing administrators.

Keep the regular administrator account created during installation and a recovery console available. In this example, the existing administrator is lfstudent and the new practice account is labops. Do not apply these sample account names to real users on a production server.

whoami
id -nG
sudo -v
sudo -l
sudo visudo -c

sudo -v verifies or renews authentication according to policy. In the default configuration, it prompts for the current general user's password and not the root password. It may be normal if no characters or asterisks appear during password input. If your organization has separate authentication policies, follow those procedures.

In the source lesson’s November 12, 2026 Rocky Linux 10.2 lab, the recorded checks confirmed lfstudent wheel, the allowed rules (ALL) ALL, and /etc/sudoers: parsed OK. The active default rule was as follows. The content below is an example of policies to read and understand, not commands to paste into files.

%wheel ALL=(ALL) ALL

%wheel means the wheel group, and the following values indicate the applicable host, target user for execution, and the range of allowed commands. This rule grants broad administrative privileges, so simply adding someone to the wheel group to let them read a single file may grant too much authority. Avoid the method of assigning it to all regular user accounts.

According to the official visudo description, -c is a check mode that does not change settings. Even if the syntax check succeeds, it does not mean that only the appropriate commands were allowed for the intended user, so the actual permissions for each user must also be verified. In this exercise, we do not modify the default sudoers.

Check for name conflicts and create a regular account.

First, check whether the name you plan to use is already registered. If results appear, it may be an existing account, so do not proceed with creation or password changes, and choose a different practice name.

getent passwd labops
id labops

getent reads information through the account lookup paths used by the system. Some servers use a central directory in addition to local accounts, so do not assume a name is available just because it is not found in a file. On this dedicated VM, we confirmed that there were no results from the lookup before creating the account.

sudo useradd -m -s /bin/bash labops
sudo passwd labops
getent passwd labops
id labops

-m creates a home directory, and -s /bin/bash specifies the login shell. Enter the password directly at the two prompts asked by passwd. Do not use a common password in the example or leave the password in command-line arguments or shell history.

The result of this VM was home path /home/labops, shell /bin/bash, and default group labops. UID and GID were 1001, but other numbers are normal depending on the existing number of users and environment. Since wheel has not been added yet, it remains a regular account. Also, from the original admin session, compare whether sudo is allowed using the following query.

sudo -l -U labops

At this stage of the exercise, the result was User labops is not allowed to run sudo. The fact that the command successfully retrieved output and the fact that the target has permissions are different. Do not assume that administrative privileges have been obtained just by looking at the exit code.

Add wheel and verify sudo in the new environment.

Run the following in the existing admin session. -a for -aG means adding a new group while keeping the existing additional groups. Using only -G wheel may omit other additional groups not in the list, so do not confuse the two forms.

sudo usermod -aG wheel labops
id labops
sudo -l -U labops

Even if 'wheel' is visible in the database lookup, we do not assume that the group of an already open session changes immediately. You can actually enter with a new console or SSH login to check, or, like in this local exercise, the existing administrator can open the new login environment of the target user using the following command.

sudo -iu labops

This command allows the administrator to open another user's environment with permitted privileges. It is different from testing the authentication procedure of logging in directly with labops' password. Run the following command inside the opened environment.

whoami
pwd
id -nG
sudo -k
sudo -v
sudo -l
sudo whoami
whoami

Check that the results identify labops, the working directory /home/labops and a group list containing wheel. In this new user's sudo -v, enter labops' own password. The last two commands should output root and labops respectively. The difference is that administrative privileges were used for a command run with sudo, while the ordinary shell retains the regular user identity.

The source lab confirmed this behavior on a Rocky Linux 10.2 guest with the sudo package 1.9.17-10.p2.el10_2.7. This is not the result of a Windows host user account or administrator privileges. If the server's policy differs, allowed commands and authentication methods may also differ, so judgment is based on the output content.

After finishing your work, running sudo -k can invalidate the current authentication cache. Check whether it prompts for authentication again on the next sudo execution. This command does not remove a user from wheel, nor does it stop any running root processes. When exiting the practiced user environment and returning to the original administrator, use exit.

sudo -k
exit

After revoking permissions, also check that they are no longer allowed.

We will revoke the permissions temporarily added for practice. This step is executed after returning to the original administrator and does not remove the currently remaining sole administrator from wheel. First, verify the user working with whoami.

whoami
sudo gpasswd -d labops wheel
id labops
sudo -l -U labops
sudo visudo -c

Compare against the wheel group list of labops to verify that wheel is removed and sudo is not allowed. In environments where permissions are granted through other individual sudoers rules or central policies, simply removing wheel may not eliminate all sudo privileges. This is why you need to re-read the per-user allowed commands even after revocation.

Open a new environment to confirm invalidation again. The groups and permissions of existing processes may remain granted, so you cannot consider revocation complete based on the outcome of a single previously opened shell.

sudo -iu labops

Within the new environment, execute the following.

id -nG
sudo -k
sudo -v
exit

In this VM, only labops remained in the group, and a denial message called Sorry, user labops may not run sudo on rocky10-lab was displayed. The previous lfstudent administrator still belonged to the wheel group and could use sudo commands. This is not a practice where the labops account itself or its home directory was deleted.

Narrow down the cause according to the error message.

Situation Checkpoints
Cannot create a user Check for an existing account with the same name, the administrative privileges of the current account, and the actual errors from user management commands.
Added to wheel, but not visible in the current group Compare id labops and the new login environment's id -nG. Do not judge based on the group of the previous session.
Password incorrect message Check which user's password the prompt is asking for and the keyboard layout. Do not expose the password in the text or shared screen.
Message that sudo cannot be executed Distinguish between simple password errors and policy denials, and request user-specific sudo -l -U and policy verification from the original administrator.
sudoers syntax error Keep the existing normal administrator and recovery console, and check the error file and line. Do not overwrite with content that grants passwordless privileges to all users.

Grant administrative privileges only to the necessary accounts and check the actual allowed range. Attaching NOPASSWD to every command to bypass password verification or opening a persistent root shell is not the goal of this exercise. The verification criteria for this course are that the required sudo actions succeed in a new regular user environment, accounts whose administrative privileges were revoked are denied, and the original administrator's access is maintained.