How to Create a New Linux User
Stop running as root. Create a sudo-capable user the right way.
Introduction
Running everything as root is dangerous. One typo can wipe the whole system. The fix: make a regular user with sudo access and use that for day-to-day work.
Create the User
- 1SSH in as root
- 2Run:
adduser yourname- 1Set a strong password when prompted
- 2Press Enter through the optional fields (name, room, etc.)
Grant Sudo Access
usermod -aG sudo yournameNow yourname can run privileged commands with sudo.
Test It
- 1Log out of root
- 2SSH back in as the new user:
ssh yourname@YOUR_VPS_IP- 1Run a sudo command:
sudo apt update- 1Type your password,
aptruns as root
You're now operating as a regular user with sudo when needed.
Copy Your SSH Key Over
ssh-copy-id yourname@YOUR_VPS_IPNow you can log in without a password.
Disable Root SSH (Optional but Recommended)
- 1Edit
/etc/ssh/sshd_config - 2Change
PermitRootLogin yestoPermitRootLogin no - 3Reload SSH:
sudo systemctl reload sshd Tip: Add your user to the adm group too, that's read access to system logs without sudo.
Warning: Don't disable root login until you've confirmed your sudo user works in a separate SSH session.
Delete a User
sudo deluser --remove-home oldnameNeed More Help?
Sudo not working? Make sure the user is in the sudo group with groups yourname. Ping us on Discord.
Was this helpful?
Your feedback helps us write better guides.
Related Articles
More from VPS Hosting.
Getting Started with Your Endercloud VPS
First-login checklist for a fresh Linux VPS, secure it before you build.
How to Connect via SSH (Windows & Mac)
Open a terminal session to your VPS, with password or, better, an SSH key.
How to Install a Web Server (Nginx / Apache)
Stand up Nginx or Apache on your VPS in five minutes.
Still need help?
Our team is on Discord around the clock. Real humans, real answers.