How to reset forgotten root password in redhat Linux server
First, reboot or power on yourĀ Redhat 8/CentOS 8 system. Select the kernel you want to boot into. Next, pressĀ āeāĀ on the keyboard to interrupt the boot process and make changes.
Locate theĀ roĀ (read-only)Ā kernel parameter as highlighted below.
Replace the kernel parameterĀ roĀ withĀ rwĀ and append an extra kernel parameterĀ init=/sysroot/bin/sh. In a nutshell, simply replace the kernel parameterĀ roĀ withĀ rw init=/sysroot/bin/sh.
Once done with making the changes, hitĀ Ctrl + XĀ combination on the keyboard to enter single-user mode.
Next, run the command below to mount the root file system in read and write mode.
:/# chroot /sysroot
You can now change the root password by executing the command:
:/# passwd root
Next, run the command below to enable SELinux relabelling. (If selinux is in enforce mode)
:/# touch /.autorelabel
To apply the changes, exit and reboot the Redhat 8/CentOS 8 system.
:/# exit
:/# reboot
Please refer here for screenshots.
https://it.techlabzone.com/how-to-reset-forgotten-root-password-in-redhat-8-centos-8/operating-system/
