How to create a user with sudo privileges
Updated 10/16/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 pricingRelated tutorials
How to check which ports are open on your server
Find out which services are listening for connections on your server and close what you do not need, for less exposure.
Updated 10/16/2026SecurityHow to scan your server for malware with ClamAV
Install ClamAV, an open-source antivirus, and periodically scan your server for infected files.
Updated 10/16/2026SecurityHow to set up your own VPN with WireGuard
Run your own private, fast and secure VPN with WireGuard on a VPS, for private browsing and secure access.
Updated 10/16/2026