Ben the DBA

Recovering the Root Password on Linux

This article provides step-by-step instructions for recovering the root password using three different methods: via GRUB, rescue mode, or single-user mode.

Method 1: Using GRUB

1. Edit GRUB at Boot:

2. Modify Kernel Parameters:

rd.break enforcing=0

3. Boot into the Modified Configuration:

4. Remount sysroot:


mount -o remount,rw /sysroot 
chroot /sysroot

5. Change the Root Password:


passwd root

6. Relabel SELinux:


touch /.autorelabel

7. Reboot the System:


exit 
exit

Method 2: Rescue Mode

1. Enter Rescue Mode:

systemd.unit=rescue.target

2. Login as Root:

3. Change the Root Password:


passwd root

After successfully resetting the root password, make sure to:

TOC

Method 1: Using GRUB
Method 2: Rescue Mode