CloudLinux.ro
Security

How to create a user with sudo privileges

Updated 7/20/2026

Working as root all the time is risky: one mistake can destroy the server. A normal user with sudo asks for your password to confirm administrative commands.

1. Create the user

adduser andrew

Set a password and fill in the requested details.

2. Grant sudo privileges

usermod -aG sudo andrew

3. Test

Log in as the new user and run a command with sudo:

su - andrew
sudo apt-get update

4. Copy your SSH keys (recommended)

So you can connect directly as the new user with keys:

mkdir -p /home/andrew/.ssh
cp ~/.ssh/authorized_keys /home/andrew/.ssh/
chown -R andrew:andrew /home/andrew/.ssh
chmod 700 /home/andrew/.ssh

Now you can safely disable root login.

Put this guide into practice on your own VPS

EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.

See pricing

Related tutorials