How to Reset Forgotten or Lost Root Password in Fedora

A Linux system administrator can quickly reset a user forgotten password using passwd command, but what happens if the system administrator itself forgets the root password? In this article, we will explain how to reset a forgotten or lost root user password in Fedora Linux distribution.

Note that to reset the lost root user password, you must have physical access to the Fedora machine in order to access Grub settings to reset and reboot the machine. Additionally, if your Fedora system is encrypted, you will also get to know the LUKS passphrase.

Edit the Fedora GRUB Settings

To edit the Fedora Grub settings, you need to interrupt the boot process by restarting the Fedora machine and press E on your keyboard when you see the following GRUB menu:

Fedora Grub Menu

Fedora Grub Menu

After pressing E on your keyboard, you will get the following screen.

Edit Fedora Grub Settings

Edit Fedora Grub Settings

Use your keyboard arrow keys and go to the line linux as shown.

Go to the line Linux" in Grub Settings

Go to the line Linux” in Grub Settings

After finding the linux line, remove rhgb quiet and replace with the following.

rd.break enforcing=0
Edit Fedora Grub Boot Settings

Edit Fedora Grub Boot Settings

Once you have done with editing the line, press Ctrl-x to save and start the system.

Note: Adding enforcing=0, bypass performing an entire system SELinux relabeling. Once the system is restarted, restore the appropriate SELinux context for the /etc/shadow file as explained below in this article.

Mounting the Fedora Filesystem

Once the system started in emergency mode, you need to remount the hard drive with read-write permission using the following command on the terminal.

# mount -o remount,rw /sysroot
Mount Fedora Drive in Read & Write Access

Mount Fedora Drive in Read & Write Access

Set Forgotten Root Password in Fedora

Now run the following chroot command to access the Fedora system.

# chroot /sysroot

You can now reset the forgotten or lost Fedora root user password using passwd command as shown.

# passwd

Enter the new root user password twice when asked. If you are successful, you should get a message that all authentication tokens updated successfully as shown.

Reset Fedora Root User Password

Reset Fedora Root User Password

Type exit, twice to reboot the system.

Set SELinux Context on Shadow File

Log in as root user and type the following command to restore the SELinux label on the /etc/shadow file.

# restorecon -v /etc/shadow

Turn SELinux back to enforcing mode.

# setenforce 1

That’s all! If you face any issues while resetting forgotten or lost Fedora root user password, do ask in the comments section below.

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Ravi Saive

I am Ravi Saive, creator of TecMint. A Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux. Follow Me: Twitter, Facebook and Google+

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

3 Responses

  1. qmxnmz says:

    It’s not only Fedora…

  2. JB says:

    If this is true, it affirms our decision to not use fedora.

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.