How to recover (reset) root password on Linux






How to recover (reset) root password on Linux

01. append a kernel parameter of rw init=/sysroot/bin/sh. This could be done by editing the GRUB menu on the fly or add the content to GRUB_CMDLINE_LINUX_DEFAULT= in /etc/default/grub.
(once you modify the parameter, make sure to run # grub2-mkconfig -o /boot/grub2/grub.cfg)

02. Next change the root dir
# chroot /sysroot

03. Lets change the root password
# passwd root

04. To rebel SELinux context the on entire system
# touch /.autorelabel

05. Finally, reboot the system.
### - see now you can login to the system as root with configured password.


0 Comments