Special Offer: Save Upto 10% on Game Servers & Bot Hosting
VPS Hosting3 min read

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

  1. 1SSH in as root
  2. 2Run:
   adduser yourname
  1. 1Set a strong password when prompted
  2. 2Press Enter through the optional fields (name, room, etc.)

Grant Sudo Access

usermod -aG sudo yourname

Now yourname can run privileged commands with sudo.

Test It

  1. 1Log out of root
  2. 2SSH back in as the new user:
   ssh yourname@YOUR_VPS_IP
  1. 1Run a sudo command:
   sudo apt update
  1. 1Type your password, apt runs 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_IP

Now you can log in without a password.

Disable Root SSH (Optional but Recommended)

  1. 1Edit /etc/ssh/sshd_config
  2. 2Change PermitRootLogin yes to PermitRootLogin no
  3. 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 oldname

Need 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.

Still need help?

Our team is on Discord around the clock. Real humans, real answers.