👤 How to Create a New Sudo User on Linux (Secure Server Setup Guide)

Vastrox

Administrator
Staff member
Owner
Joined
May 29, 2025
Messages
30
Reaction score
0
Points
6

👤 How to Create a New Sudo User on Linux (Secure Server Setup Guide)​


Setting up a new server? One of the first and most important steps is to create a new user with sudo privileges instead of using the root account.


This guide will walk you through how to create a secure sudo user on Linux, so you can manage your system safely — ideal for VPS, dedicated servers, and production environments.


🔐 At Vastrox.com, we help developers and sysadmins build secure Linux-based infrastructures with speed, clarity, and best practices.



✅ Why Use a Sudo User Instead of Root?​


Using root for everything can be dangerous. One wrong command could break your server instantly. Creating a regular user with elevated privileges (via sudo) is a safer and more professional way to manage Linux systems.


Here’s why you should create a sudo user:


  • 🛡️ Reduces risk of accidental system damage
  • 👥 Allows secure access for multiple team members
  • 🔒 Enables better control and auditing
  • ⚙️ Required for production-ready deployments (including tools from Vastrox)



🧰 What You’ll Need​


  • Access to your server (SSH or console)
  • Root access (or a user with sudo privileges)
  • A server running Ubuntu, Debian, CentOS, AlmaLinux, or another Linux distro



🧩 Step 1: Log In to Your Server​


Use SSH to access your server as root:


ssh root@your-server-ip

Or via your hosting panel’s terminal access.




👤 Step 2: Create the New User​


To create a new user (replace username with your preferred name):


adduser username

You’ll be prompted to set a password and fill in optional details like name and contact info. You can leave those blank and press Enter to skip.




🔐 Step 3: Grant Sudo Privileges​


Once the user is created, add them to the sudo group:


For Ubuntu/Debian:


usermod -aG sudo username

For CentOS/RHEL/AlmaLinux:


usermod -aG wheel username

✅ This allows your new user to run administrative commands using sudo.




🔁 Step 4: Test the New Sudo User​


Now, switch to your new user account:


su - username

Try running a command with sudo:


sudo whoami

If the output is root, the sudo permissions are working correctly.




🛡️ Step 5 (Optional): Disable Root Login via SSH​


To boost security, you can prevent direct root login via SSH:


  1. Open the SSH configuration file:

sudo nano /etc/ssh/sshd_config

  1. Find this line:

PermitRootLogin yes

  1. Change it to:

PermitRootLogin no

  1. Save and restart SSH:

sudo systemctl restart sshd

Now, your server can only be accessed by trusted sudo users.




🧠 Final Tips​


  • Always create a secure password for each user
  • Consider using SSH key authentication instead of passwords
  • Add only trusted users to the sudo group
  • Keep a backup access method in case of lockouts
  • Use Vastrox deployment tools to automate and secure server provisioning with best practices



🚀 Build Safer Servers with Vastrox​


Creating a sudo user is just the beginning. With Vastrox.com, you get access to:


  • Secure server automation tools
  • One-click deployment templates
  • Global DNS + firewall protection
  • Developer-ready Linux stacks with built-in hardening

Whether you're launching a game server, a website backend, or cloud services — Vastrox helps you do it smarter, faster, and safer.




✅ Conclusion​


You’ve successfully created a new sudo user on your Linux server — a foundational step for secure and scalable infrastructure management.


For more Linux tutorials, optimization tips, and deployment guides, visit Vastrox.com.
We’re here to help you build better from the command line up.



 
Top