Root user is the most powerful user in Linux systems , What if we lost Root Password for any reason and we need to do some troubleshooting or maintenance , you would need root privileges , so you must be able to retain Root Password , Let’s see how to do it ….
01. Reboot Your Linux machine:
Select your boot option and press e
02. Add rd.break to the line that start with linux16:
You may add rd.break this near the end or any where, it sill stop kernel from normal booting and put it where we can do our simple job .
Now Press CTRL+X keys to start
03. Remount , chroot , passwd :
The system root is mounted as read-only but we need it as Read/Write before we chroot to it and change root password.
mount -o remount,rw /sysroot chroot /sysroot passwd root touch /.autorelabel exit exit
It may take some time as /.autorelabel will force SELinux to correct any labels , please wait till it done.
Now after it finish , system will reboot, use your new Root Password.
That is it , I hope it was simple , Thanks