Using the root account for everyday administration is risky — a single mistyped command can affect the entire system. Creating a dedicated user with sudo privileges lets you perform administrative tasks safely while keeping day-to-day work under a limited account.
Prerequisites
- Root or existing sudo access to your VPS
- An active SSH session
Step 1 — Create the New User
On Ubuntu and Debian:
adduser newuser
You'll be asked to set a password and, optionally, additional profile details (these can be left blank).
Step 2 — Grant Sudo Privileges
On Ubuntu and Debian, add the user to the sudo group:
usermod -aG sudo newuser
On RHEL-based distributions (AlmaLinux, Rocky Linux, CentOS), use the wheel group instead:
usermod -aG wheel newuser
Step 3 — Verify Group Membership
groups newuser
You should see sudo (or wheel) listed.
Step 4 — Test Sudo Access
su - newuser
sudo whoami
Enter the user's password when prompted. If configured correctly, the command returns:
root
Step 5 — Log In via SSH as the New User
From your local machine, in a new terminal window (keep your current session open):
ssh newuser@YOUR_SERVER_IP
Optional — Add an SSH Key for the New User
ssh-copy-id newuser@YOUR_SERVER_IP
Checking Sudo Privileges
sudo -l
This shows which commands the current user is permitted to run with sudo.
Removing Sudo Access
deluser newuser sudo
Deleting a User
deluser --remove-home newuser
Common Errors
"newuser is not in the sudoers file" — the user wasn't added to the correct group, or you need to log out and back in for group membership to take effect.
sudo: command not found — sudo isn't installed; install it with apt install sudo (as root) first.
Best Practices
- Use this account for all routine administration instead of root
- Prefer SSH keys over passwords for this account
- Only disable root SSH login after confirming this account works correctly
FAQ
What's the difference between the sudo and wheel groups?
They serve the same purpose — sudo is used on Debian/Ubuntu, wheel on RHEL-based distributions like AlmaLinux and Rocky Linux.
New to VPS For Life? If you haven't ordered your VPS yet, browse our VPS hosting plans to get started, or contact our support team if you need help choosing the right one.
Continue Reading
- How to Connect to Your VPS via SSH (Windows, macOS & Linux)
- SSH Hardening: Change the Port, Disable Root Login & Use SSH Keys
- VPS Security Checklist for Beginners
Browse more articles in Getting Started / VPS Basics.
