How to recovery root password on Red Hat 8 / Centos 8 / Rocky Linux 8?

# ROOT PASSWORD RECOVERY
## in Grub menu delete rhgb, quite and add “rd.break” to kernel parameters line
## …kernel =auto …. rd.break
ctrl + x

# /dev/mapper/rhel-root on /sysroot mounted as read only,

# mount command will show the status of /sysroot

mount

# So remount needed for RW mode
mount -o remount,rw /sysroot

# mount command for verify
mount

# Because of initramfs files is not in right location
# To change it
chroot /sysroot

# reset password for root with “secret” password
echo secret | passwd –stdin root

# or use: passwd root

# This is necessary for SE Linux.  Very very IMPORTANT !!!
touch /.autorelabel

ctrl + d
ctrl + d

### Takes at least two minutes reboot and to open OS on VM

By:

Posted in:


Leave a comment