aoitcloud

Fedora

Creating a new sudo user on Fedora

A quick, practical walkthrough for creating a new user on Fedora and granting them sudo access via the wheel group - the standard RHEL-family approach.

22 November 2024 3 min read

If you’ve just provisioned a Fedora VPS, you’ll usually be logging in as root to start with. Working as root all the time is a bad habit – one mistyped command can do real damage with no safety net. The standard fix is to create a normal user account and grant it sudo access for when you need elevated privileges. Here’s how to do that on Fedora.

1. Create the user

Log in as root (or as an existing sudo user) and create the new account. Replace alex with whatever username you want throughout this guide.

sudo useradd -m alex

The -m flag creates a home directory for the user (/home/alex) if one doesn’t already exist. If you’re doing this as root rather than via sudo, you can drop the sudo prefix.

2. Set a password

The new account needs a password before it’s usable for login:

sudo passwd alex

You’ll be prompted to enter and confirm a password. Use something strong – this account is about to be granted administrative access.

3. Add the user to the wheel group

Fedora, like the rest of the RHEL family (RHEL itself, AlmaLinux, Rocky Linux, CentOS Stream), grants sudo access via membership of the wheel group, rather than a distinct sudo group as Debian and Ubuntu use. Fedora’s default /etc/sudoers configuration already has the rule enabled that lets members of wheel run any command via sudo – you don’t need to edit sudoers yourself for this to work.

Add your new user to the group:

sudo usermod -aG wheel alex

The flags matter here. -a means “append” – add this group without removing the user from any groups they’re already in. -G specifies the group(s) to add. Leaving off -a is a classic mistake: usermod -G wheel alex on its own replaces the user’s supplementary group list entirely, potentially knocking them out of other groups they needed.

4. Verify group membership

Confirm the user was added correctly:

groups alex

You should see wheel listed among the groups in the output.

5. Test sudo access

Switch to the new user, or log in as them via SSH, then try a command that requires elevated privileges:

su - alex
sudo whoami

You’ll be prompted for the user’s own password (not root’s) – that’s expected, sudo authenticates against the account running the command. Enter it, and the output should read root, confirming sudo is working correctly.

If a group change doesn’t seem to have taken effect in an existing SSH session, log out and back in – group membership is applied at login, so an active session won’t pick up a newly added group until you reconnect.

A note on locking things down further

Once you’ve confirmed the new account works, it’s worth disabling direct root login over SSH and switching to key-based authentication for your new user, so root access is only ever available via sudo from an authenticated account. That’s outside the scope of this post, but it’s the natural next step once your sudo user is set up.

Get in touch

Drop our team a message today