🔐 How to Change the Root Password in Linux (Step-by-Step Guide)

Vastrox

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

🔐 How to Change the Root Password in Linux (Simple Guide for Beginners)​


Need to reset or update your root password on a Linux server? Whether you're securing a new VPS or tightening your system access, this step-by-step guide shows you exactly how to change the root password safely and easily.


This works for all major Linux distributions including Ubuntu, Debian, CentOS, AlmaLinux, and more.


At Vastrox.com, we help developers, teams, and server owners manage secure, optimized Linux infrastructure — with powerful tools and guides just like this.



✅ Why Change the Root Password?​


  • 🆕 You're setting up a new server
  • 🧠 You forgot the previous root password
  • 🔐 You’re concerned about unauthorized access
  • 📈 You're preparing for production or automation with Vastrox tools
  • 🛡️ You want to follow best practices for server hardening



🧰 What You’ll Need​


  • Terminal or SSH access
  • Sudo privileges or current root access
  • A Linux-based server (any major distro)

✅ Tip: Vastrox supports Ubuntu, Debian, CentOS, AlmaLinux, Rocky Linux, Arch Linux, and more.



🧩 Step 1: Connect to Your Server​


To log in as root, use:


ssh root@your-server-ip

Or log in with a regular sudo user:


ssh yourusername@your-server-ip



🔐 Step 2: Change the Root Password​


If you are already root, just run:



Using a sudo-enabled user:


sudo passwd root

You'll be asked to enter and confirm a new password.
🛡️ Use a strong password — a mix of uppercase, lowercase, numbers, and special characters.




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


To prevent root login over SSH (recommended):


  1. Open the SSH config file:

sudo nano /etc/ssh/sshd_config

  1. Find this line:

PermitRootLogin yes

  1. Change it to:

PermitRootLogin no

  1. Restart the SSH service:

sudo systemctl restart sshd

✅ Now, only sudo users can log in — reducing the risk of brute-force attacks.




🔁 Step 4: Test Your New Password​


Log out and log back in as root:


ssh root@your-server-ip

If the login works, you’re all set!




⚠️ Common Issues & Fixes​


🔧 Problem: Authentication token manipulation error
✅ Fix: Make sure you used sudo and the root account is unlocked.


🔧 Problem: "passwd: command not found"
✅ Fix: Install the utility:


Ubuntu/Debian:


sudo apt install passwd

CentOS/RedHat:


sudo yum install passwd



🚀 Want Better Linux Hosting & Tools?​


If you're managing private servers, web panels, or game infrastructure, explore what Vastrox.com has to offer:


  • ⚙️ Secure, developer-friendly server tools
  • 🌍 Global performance and CDN integration
  • 🧠 Beginner-friendly guides like this
  • 🛡️ Built-in security best practices for production environments

Whether you're solo or scaling with a team, Vastrox helps you deploy faster and stay in control.




🧠 Final Tips​


  • Don’t share the root password — use sudo accounts instead
  • Use SSH keys for better security over passwords
  • Disable root login when possible
  • Regularly audit server access and credentials
  • Enhance your server stack with Vastrox DNS & Firewall tools



✅ Conclusion​


You’ve successfully updated your Linux root password — a critical step in securing your system.


For more tutorials on Linux server management, deployment optimization, and security best practices, visit Vastrox.com.


We’re here to help you build faster, safer, and smarter.
 
Last edited:
Top