reset root password

Log in to a system and change the root password when the current root password has been lost.

Break into the rhel9 OS and change root user's password,

after changing root password, change hostname permanently


Solution 1:

Press ESC to launch GRUB2 menu, press E to edit the loader, find linux kernel loading line, add following string at the end of line:

rd.break console=tty1 rw

Then press CTRL+X to save and load the OS. After OS loads, type this commands:

chroot /sysroot
passwd root
touch /.autorelabel
/usr/sbin/reboot -f

Solution 2:

Press ESC to launch GRUB2 menu, press E to edit the loader, find linux kernel loading line, add following string at the end of line:

rd.break

Then press CTRL+X to save and load the OS. After OS loads, type this commands:

mount -o remount,rw /sysroot
chroot /sysroot
passwd
touch /.autorelabel
/usr/sbin/reboot -f

Solution 3:

Press ESC to launch GRUB2 menu, press E to edit the loader, find linux kernel loading line, add following string at the end of line:

rw init=/bin/bash

Then press CTRL+X to save and load the OS. After OS loads, type this commands:

passwd root
touch /.autorelabel
/usr/sbin/reboot -f

Changing hostname:

hostnamectl status
hostnamectl set-hostname new-name

Last updated

Was this helpful?