Home / Linux / How to Create a New User and Give Sudo Access

How to Create a New User and Give Sudo Access

Create a new Linux user for VPS administration and grant sudo privileges safely, with detailed commands and verification.

Views: 20 Unique: 17 Updated: 2026-03-20

What this is

This procedure creates a new Linux user and grants administrative privileges using sudo.

What it is for

  • Avoid using root for daily work (more secure)
  • Give each admin their own account (audit and control)
  • Prepare for disabling root SSH login later

Prerequisites

  • SSH access as root or an existing sudo user
  • A username you want to create (example: admin)

Step-by-step

Step 1) Create the user

Ubuntu/Debian (recommended command):

sudo adduser admin

What it does: Creates the user and a home directory, and asks for a password.

Expected output: Prompts to set a password and optional user info.

RHEL/CentOS/Rocky/Alma (common command):

sudo useradd -m admin
sudo passwd admin

What it does: Creates the user (-m creates the home folder) and sets a password.

Step 2) Add the user to the sudo/admin group

Ubuntu/Debian

sudo usermod -aG sudo admin

What it does: Adds the user to the sudo group.

Why it is needed: Members of sudo can run admin commands.

RHEL/Rocky/Alma/CentOS

sudo usermod -aG wheel admin

What it does: Adds the user to the wheel group (sudo equivalent).

Step 3) Test sudo access

Switch to the new user:

su - admin

Expected output: Your prompt changes and you are now the new user.

Test sudo:

sudo whoami

What it does: Runs whoami as root using sudo.

Expected output: root

Warnings & notes

  • Do not delete or lock your only sudo user, or you may lose admin access.
  • For better security, use SSH keys instead of passwords.

Final verification

From the new user account, run:

sudo -l

Expected output: A list of allowed sudo commands (or “(ALL) ALL”).

Conclusion

You now have a safer admin user. Next best step is to configure SSH keys and optionally disable root SSH login.

Back to category