How to Reset a Forgotten Root Password in Fedora

This brief article explains the steps you can take to reset your forgotten root password on a Fedora Linux system. For this guide, we are using Fedora 32.

Read Also: How to Reset Forgotten Root Password in CentOS 8

First, you need to reboot or power on your system and wait until the grub menu is displayed as shown below.

Fedora Grub Menu
Fedora Grub Menu

Press 'e' to edit the grub parameters. This ushers you to a display shown below. Next, locate the line beginning with 'linux' as shown below.

Locate Grub Kernel Parameter
Locate Grub Kernel Parameter

Using the Cursor forward Arrow key, navigate to the section with the rhgb quiet parameter.

Kernel rhgb quiet Parameter
Kernel rhgb quiet Parameter

Now replace the rhgb quiet parameter with rd.break enforcing=0.

Change Grub Kernel Parameter
Change Grub Kernel Parameter

Next press ctrl + x to boot into single-user mode. Next, remount the root filesystem in read and write mode.

# mount –o remount,rw /sysroot
Mount Root Filesystem in Fedora
Mount Root Filesystem in Fedora

Next, run the command below to gain access to the Fedora system.

# chroot /sysroot

To change or reset the root password simply issue the passwd command as shown.

# passwd
Reset Root Password in Fedora
Reset Root Password in Fedora

Provide a new password and confirm it. If all went well, a notification ‘password updated successfully‘ will be displayed at the end of the console.

To reboot the system, simply hit Ctrl + Alt + Del. You can thereafter log in as the root user using the newly created root password.

Upon logging in, run the command below to restore SELinux label to the /etc/shadow file.

# restorecon -v /etc/shadow

And finally set SELinux to enforcing mode using the command.

# setenforce 1

And this concludes our topic on how to reset a forgotten root password on Fedora 32. Thank you for taking the time on this tutorial.

Two small things before you go

If something didn’t work on your setup, leave a comment and tell me which distro and version you’re on. I read every one, and most of these articles got better because a reader pointed out what was missing.

And if it did work, share it. TecMint has stayed free for 14 years because people pass these articles around, and that traffic is what pays for writing the next one.

Leave a comment
Get two free Linux courses

Learn the Linux basics with two free courses and join 34,000+ readers getting practical TecMint tutorials and selected Pro TecMint articles every week.

Pro TecMint
Get lifetime access for $99

If you want to go beyond the free tutorials, Pro gives you 18 courses, 5 ebooks, and every future course I add. One payment, lifetime access, no renewals.

James Kiarie
James Kiarie
Contributor
About the author

This is James, a certified Linux administrator and a tech enthusiast who loves keeping in touch with emerging trends in the tech world. When I'm not running commands on the terminal, I'm taking listening to some cool music. taking a casual stroll or watching a nice movie.

4 Comments

Leave a Reply
  1. Thank you for the very clear explanation on how to reset the root password in Fedora 32. When I try it on my Fedora 33 system, after changing “rhgb quiet” with “rd.break enforcing =0” and pressing Ctrl-x to boot into single-user mode, I receive a request for the root password OR Ctrl-D to continue.

    Clearly, I don’t have the root password, and the latter choice (Ctrl-D) just loads the system as normal. Any suggestions? Thank you once again for your article. Best regards, Derek

    Reply
  2. Cannot log in after a power failure on Fedora Linux 30.

    Will not accept the root or user password. Have to recover by resetting the root password. Any ideas?

    Reply
  3. Disabling SELinux does eliminate the need for relabeling the entire drive after a password reset.

    Does this work if the disk is LUKS encrypted? Would you need to run vgchange -a to get access to it?

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.