Knowledgebase

Reset lost root password dedicated server (in rescue mode)

Resetting the root password in rescue mode is a useful procedure if you've forgotten the root password for your Linux system. Rescue mode provides a way to access your system in a minimal environment, allowing you to reset the root password. Here's a step-by-step tutorial on how to do this:

Note: This tutorial assumes that you have physical access to the machine or access to the virtualization platform (if the Linux system is virtualized) to boot into rescue mode.

Step 1: Boot into Rescue Mode

In our client area, select the desired dedicated server and boot it in rescue mode.

Sysrcd 6.1.6 [rescue system]

Step 2: Mount the Root Filesystem

The system will boot into rescue mode, and you'll be presented with a command prompt. First, you need to mount the root filesystem to make changes to it. Run the following commands:

# Identify your root partition (usually /dev/sda1, /dev/nvme0n1p1, or similar)
fdisk -l

# Mount the root partition to /mnt
mount /dev/sdXY /mnt


Replace
/dev/sdXY with the correct root partition you identified in the previous step.

Step 3: Chroot into the Root Filesystem

Now, you need to change the root environment to your actual system's root filesystem. This is done using the chroot command:

chroot /mnt


Step 4: Reset the Root Password

With the root filesystem mounted and chrooted, you can reset the root password using the passwd command:

passwd


You'll be prompted to enter a new root password. After setting the new password, you'll likely see some password-related messages, indicating that the password has been updated successfully.

Step 5: Unmount and Reboot

Exit the chroot environment:

exit


Now, unmount the root partition:

umount /mnt


Finally, reboot your system:

reboot


After the system restarts, you should be able to log in with the new root password you just set.

That's it! You've successfully reset the root password in rescue mode on your Linux system. Be sure to keep your new password in a secure place to avoid this situation in the future.

 

Was this answer helpful?

 Print this Article

Also Read

Scan CentOS server for viruses and malware

Introduction Some unexpected behavior on a Linux server can be caused by a malware infection....

Mail servers on Cloud VPS

At SpectraIP, the reputation of our network and IP addresses is very important and we are...

Getting started with One-click LEMP stack (Nginx with PHP and MariaDB)

Introduction SpectraIP's one-click LEMP application is an easy way to deploy web applications on...