This guide explains how to reset a lost or forgotten root password on your Linux server using the rescue mode.
Prerequisite: Your server must be booted into the Linux Rescue System and you must be connected via SSH. → Starting rescue mode
First identify your root partition with lsblk — it is usually the largest partition. Then mount it and enter the chroot environment:
/dev/sda3 is an example — your root partition may differ. Use the lsblk output to find the correct device name.
First assemble the RAID arrays, then mount the root RAID device and enter the chroot environment:
/dev/md2 is an example — your root RAID device may have a different number. Use lsblk or cat /proc/mdstat to find the correct one.
While inside the chroot, run the following command and enter your new password twice when prompted:
You will see a confirmation once the password is updated successfully:
Exit the chroot environment and the SSH session:
Go to your PowerPanel and cancel rescue mode to reboot the server back into its normal operating system with your new password. → Cancelling rescue mode
For more information on Linux user management and password policies, refer to the official Linux documentation.