This page explains step to reset the root password on fedora 26 machine incase user has forgotten password.
To reset the system password, need the physical access to the system because need to reboot and access the GRUB setting.
We also need LUKS passphrase if system is encrypted.
1. Reboot the system and press e when you see the fedora kernel or GRUB menu (like below).
2. Identify the line which is starting linux16 and replace rd.break enforcing=0 instead of rhgb quiet. Setting enforcing=0, avoids performing a complete system SELinux relabeling. Once rebooted with new pasword, need to update the required SELinux context.
3. Pres control + x to start the system, then needs to provide LUKS passphase if system is encrypted.
4. Currently system is in emergency mode, need to mount the hard drive with read-write access.
# mount –o remount,rw /sysroot
5. Run chroot to access the system.
6. Provide the new root user password,
Will ask password and confirm password to set the root user password.
7. Run exit command twice to reboot the system.
8. Now you can login as root user with new password, then restore shadow file ‘/etc/shadow’.
# restorecon -v /etc/shadow
you can also set the required SELinux mode,