Rescue Mode

How can we help?

Guides and technical documentation for your Server4You dedicated server or VPS.

Reset Linux Root Password

This guide explains how to reset a lost or forgotten root password on your Linux server from the rescue system using chroot and passwd — for servers with and without software RAID.

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.

On AlmaLinux and Rocky Linux (SELinux enabled), first run touch /.autorelabel inside the chroot so file labels are restored on the next boot; this boot takes longer. Then exit the chroot environment and the SSH session:

Terminal
exit exit

Further Documentation

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