This guide will provide you with an information on how to reset lost root ( administrator ) password on RHEL / CentOS 7
- Start or reboot a system to get into the boot menu.
- Press any key to stop the auto selection of a menu item.
- Ensure the kernel you intend to boot into is highlighted and press the E key to edit the entry.
- Navigate to the”linux16″ kernel line and hit the End key to go to the end of the line.
- Append rd.break to the linux16 kernel line.
- Hit Ctrl + X to continue.
- The system boots into an emergency mode that has the /sysroot directory mounted as read only.
- Mount the /sysroot directory with read and write permissions.
mount -oremount, rw /sysroot
- Switch into chroot jail and set the /sysroot as the root file system.
- Reset the root password.
- Cleanup. Make sure that all unlabeled files get relabeled during the boot process for SELinux.
- Exit chroot jail.
- Exit the initramfs debug shell.