https://fedoraproject.org/wiki/How_to_reset_a_root_password
While booting the system the GRUB2 menu will be displayed, to boot the system using bash follow these steps:
- Use the arrow keys to select the boot entry you want to edit
- Press e to start editing that entry
- Use the arrow keys to go to the line that starts with linux or linux16
- If you have a UEFI system it's the line that starts with linuxefi
- Go the the end of that line add a space then rw then another space and init=/bin/bash
- If your disk is encrypted, you may need to add plymouth.enable=0 as well
- Press Ctrl-x or F10 to boot that entry
Changing root password
As root, changing password does not ask for your old password. Run the command:
# passwd
Enter your new root password twice. Congratulations! You now have now reset your root password.
To make sure that selinux context of file which were now modified is restored properly after reboot, run:
# touch /.autorelabel
You can than reboot the machine with
# /sbin/reboot -f