Why You Might Need to Change the Root Password
Changing the root password is a basic yet essential security measure for anyone managing a Linux server. Whether you suspect a breach, want to improve security, or simply forgot the original root password, this guide will walk you through it safely.
Pro Tip: Always use a strong password with a mix of letters, numbers, and symbols.
Prerequisites
Before you begin, make sure you have:
-
Root or sudo privileges
-
SSH access to your server
-
A terminal (like PuTTY or your local shell)
✅ Method 1: If You’re Already Logged In as Root
-
Open the terminal or SSH into your server.
-
Type the following command:
-
Enter your new root password when prompted.
-
Confirm it again.
-
You’ll see a message like:
password updated successfully
Method 2: If You’re Using a Sudo User
-
SSH into the server using your sudo user.
-
Type:
-
Enter your own sudo password if prompted.
-
Enter and confirm the new root password.
Forgot Root Password? (Recovery Mode)
If you're locked out and can access the server through a console or GRUB boot:
-
Reboot the server and enter GRUB menu.
-
Choose the default kernel and press
e
to edit. -
Find the line starting with
linux
, go to the end, and add: -
Press Ctrl + X or
F10
to boot. -
Once in bash, remount the system:
-
Now reset the password:
-
Enter your new password.
-
Type:
-
Reboot and log in with the new root password.
Final Tips for Root Password Security
-
Use long, complex passwords.
-
Disable direct root login and use a sudo user for routine tasks.
-
Consider using SSH keys instead of passwords.
Need Help?
If you're hosting with Vastrox and run into trouble, our support team is available 24/7 to assist with server access and security. Contact Support