Hostxpeed
Login Get Started →
Getting Started

How to Create a New Sudo User

6 min read
21 views
Jun 10, 2026

Prerequisites

Before creating a new sudo user, make sure you have:

  • SSH access to your VPS as root (username: hxroot)
  • Your server IP address
  • Root password

Why Create a Sudo User?

Using the root account for daily tasks is a security risk. A sudo user can:

  • Run administrative commands only when needed
  • Have their own password and SSH key
  • Provide an audit trail of commands
  • Reduce the risk of accidental system damage

Step 1: Connect to Your VPS as Root

Open your terminal (Mac/Linux) or PuTTY (Windows) and connect:

ssh hxroot@YOUR_SERVER_IP -p 22

Enter your root password when prompted.

Step 2: Create a New User

Replace username with your desired username:

adduser username

You will be prompted to:

  1. Enter and confirm a password for the new user
  2. Enter user information (optional - you can press Enter to skip)
Adding user `john' ...
Adding new group `john' (1001) ...
Adding new user `john' (1001) with group `john' ...
Creating home directory `/home/john' ...
Copying files from `/etc/skel' ...
New password: 
Retype new password: 
passwd: password updated successfully

Step 3: Add User to Sudo Group (Ubuntu/Debian)

Give the user administrative privileges:

usermod -aG sudo username

Step 3 Alternative: For CentOS/Rocky/AlmaLinux

On RHEL-based systems, use the wheel group:

usermod -aG wheel username

Step 4: Verify Sudo Access

Switch to the new user and test sudo:

su - username
sudo whoami

You should see:

root

Step 5 (Optional): Set Up SSH Key for New User

For passwordless login (more secure):

On your local machine, copy your SSH key:

ssh-copy-id username@YOUR_SERVER_IP

Step 6 (Optional): Disable Root Login (Advanced Security)

After confirming your sudo user works, you can disable root SSH access:

sudo nano /etc/ssh/sshd_config

Find and change:

PermitRootLogin no

Then restart SSH:

sudo systemctl restart sshd

⚠️ Warning: Only disable root login after you have confirmed your sudo user can run commands with sudo.

Common Sudo Commands

  • sudo apt update - Update package lists
  • sudo systemctl restart nginx - Restart a service
  • sudo nano /etc/hosts - Edit system files
  • sudo ufw enable - Enable firewall

Was this article helpful?