Creating a new sudo user on Oracle Linux
A step-by-step guide to creating a non-root user with sudo privileges on Oracle Linux, and verifying it actually works before you log out of root.
5 November 2024 3 min read
Working from root for daily administration is risky – there’s no confirmation prompt standing between you and a destructive typo. The fix on Oracle Linux, as with any RHEL-family distribution, is to create a personal account and grant it sudo privileges through the wheel group. Here’s the full process.
1. Create the new user
Connect to your VPS as root (or an existing sudo user) and run:
useradd yourusername
Swap in whatever username you’d like. This creates the account, a home directory at /home/yourusername, and a default shell.
2. Set a password
The new account can’t log in until it has a password:
passwd yourusername
Enter and confirm a strong password. Because this account will shortly gain root-equivalent power via sudo, give it the same level of care you’d give the root password.
3. Add the user to the wheel group
Oracle Linux, like RHEL, AlmaLinux and Rocky Linux, grants sudo access to members of the wheel group. Add your user to it:
usermod -aG wheel yourusername
The -a flag is important – it appends the wheel group to the user’s existing group memberships instead of replacing them. Forgetting it is a common way to accidentally strip a user’s other group access.
4. (Optional) Set up SSH key authentication
If you’d rather log in with an SSH key than a password, set up the .ssh directory with correct permissions:
mkdir -p /home/yourusername/.ssh
chmod 700 /home/yourusername/.ssh
nano /home/yourusername/.ssh/authorized_keys
Paste in your public key, save the file, then correct its permissions and ownership:
chmod 600 /home/yourusername/.ssh/authorized_keys
chown -R yourusername:yourusername /home/yourusername/.ssh
5. Verify sudo access before you log out of root
Don’t close your root session yet. Open a second terminal and log in as your new user:
ssh yourusername@your-server-ip
Then confirm sudo actually works:
sudo whoami
Enter the new user’s password when prompted (not root’s). If the command returns root, sudo is correctly configured, and you can safely disable direct root SSH login if that’s part of your hardening plan.
From here, package management, firewall configuration and service management on Oracle Linux work the same as on any other RHEL-family distribution – see our guides on managing packages with dnf, firewalld basics, and managing services with systemd. If you’re curious what’s genuinely different about Oracle Linux beyond user management, see our post on what Oracle Linux is and whether the “Unbreakable” name is deserved.