How to reset lost or forgotten root password in Fedora Linux 31

What happens if the system administrator forgets the root password? No worry, this post will demonstrate how to reset a lost or forgotten root password in Fedora Linux 31. You may take a KVM console If your system have a management console connected. Please note that it is better to have physical access to the machine in order to reboot and to access GRUB settings. There are two ways to reset forgotten root password.
1. Fedora Live Media
2. Rescue Mode
In this guide, we will reset lost or forgotten root password using Rescue Mode.
Also Read: How to reset forgotten root password of RedHat and CentOS 7 Linux
Also Read: Fedora Linux 31 Workstation Installation Steps with Screenshots
Step 1 – Edit the GRUB Menu
Interrupt booting process holding “Shift” key while loading GRUB, if you boot using BIOS. If your system boots using UEFI, press “Esc” key.

Step 2 – Edit GRUB
Press ‘e’ when you see the GRUB menu  to edit GRUB
Note: You can press “Esc” key any time to exit from while editing GRUB without saving it.
Go to the line starts with “linux16”, “linux” or “linuxefi” and add “rw init=/bin/bash” at the end of line after adding space.
Note: Add “plymouth.enable=0” if your disk is encrypted.
Press ‘Ctrl+x’ or F10 to boot.

Step 3 – change root password
Command prompt will appear after exiting from GRUB editing screen. Run command ‘passwd’ from command prompt to change root password. It will prompt you to enter the new root password twice.
# passwd

Step 4 – Restore the SELinux context and permissions with below command
# touch /.autorelabel
Reboot the system

# /sbin/reboot -f

Step 5 – SELinux will be relabeling its permissions on the filesystem which may take time to boot. Once it is done, the machine will be ready to accept newly change root password.

Login with newly reset root password.

Note: If the normal user account has sudo rights, ‘sudo password‘ might do the wonder for your.
Conclusion: In this tutorial, we have seen “how to reset lost or forgotten root password in Fedora Linux 31″. Big thanks for reading all the way to the end. Please share it with Your Friends & Help Someone… and also Like Our Facebook Page. Let me hear your thoughts in the comments below!

Leave a Comment