Reset Linux Root Password

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

Step 1: Mount the Filesystem

The commands differ depending on whether your server uses software RAID or not.

Non-RAID Server

First identify your root partition with lsblk — it is usually the largest partition. Then mount it and enter the chroot environment:

Terminal
lsblk mount /dev/sda3 /mnt chroot /mnt

/dev/sda3 is an example — your root partition may differ. Use the lsblk output to find the correct device name.

RAID Server

First assemble the RAID arrays, then mount the root RAID device and enter the chroot environment:

Terminal
mdadm --assemble --scan mount /dev/md2 /mnt chroot /mnt

/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.

Step 2: Reset the Root Password

Run the passwd command inside the chroot environment.

While inside the chroot, run the following command and enter your new password twice when prompted:

Terminal
passwd root

You will see a confirmation once the password is updated successfully:

Terminal
New password: Retype new password: passwd: password updated successfully

Step 3: Exit and Reboot

Leave the chroot and SSH session, then cancel rescue mode via the PowerPanel.

Exit the chroot environment and the SSH session:

Terminal
exit exit

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

Further Documentation

For more information on Linux user management and password policies, refer to the official Linux documentation.