How to Create a New User with Sudo Access on a Linux VPS

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

Browse more articles in Getting Started / VPS Basics.

  • sudo access, create user, linux user management, vps basics, ubuntu
  • 0 Корисниците го најдоа ова како корисно
Дали Ви помогна овој одговор?

Понудени резултати

How to Connect to Your VPS via SSH (Windows, macOS & Linux)

SSH (Secure Shell) is the standard way to remotely access and manage a Linux VPS. This guide...

How to Check VPS Resource Usage (CPU, RAM & Disk)

Monitoring your VPS's resource usage helps you catch performance problems before they cause...

How to Reboot a Linux VPS Safely

Rebooting is sometimes required — after a kernel update, to apply certain configuration...

VPS Terminology: A Beginner's Glossary

New to VPS hosting? This glossary explains the most common terms you'll encounter while setting...

How to Choose the Right VPS Plan for Your Workload

Picking the wrong VPS size is one of the most common beginner mistakes — too small and your...