Home Fedora How To Reset Root Password In Fedora 36

How To Reset Root Password In Fedora 36

Reset Forgotten Root Password In Fedora

By sk
5.2k views

Have you forgotten the root password in Fedora? Or do you want to change the root user password in your Fedora system? No problem! This brief guide walks you through the steps to change or reset root password in Fedora operating systems.

Note: This guide has been officially tested on Fedora 36 and 35 versions. The steps provided below are same for resetting root password in Fedora Silverblue and older Fedora versions.

Step 1 - Switch on your Fedora system and press ESC key until you see the GRUB boot menu. Once the GRUB menu is appeared, choose the Kernel you want to boot and hit e to edit the selected boot entry.

Grub Menu In Fedora 36
Grub Menu In Fedora 36

Step 2 - In the next screen, you will see all boot parameters. Find the parameter named ro.

Find ro Kernel Parameter In Grub Entry
Find ro Kernel Parameter In Grub Entry

Step 3 - Replace the 'ro' parameter with 'rw init=/sysroot/bin/sh'(without quotes, of course). Please mind the space between "rw" and "init=/sysroot...". After modifying it, the kernel parameter line should look like below.

Modify Kernel Parameters
Modify Kernel Parameters

Step 4 - After changing the parameters as shown above, press Ctrl+x to enter into the emergency mode i.e. single user mode.

From the emergency mode, enter the following command to mount root (/) file system in read/write mode.

chroot /sysroot/
Mount Root Filesystem In Read, Write Mode In Fedora Linux
Mount Root Filesystem In Read, Write Mode In Fedora Linux

Step 5 - Now change the root password with passwd command:

passwd root

Enter the root password twice. I suggest you to use a strong password.

Reset Or Change Root Password In Fedora
Reset Or Change Root Password In Fedora

Step 6 - After resetting the root password, run the following command to enable SELinux relabeling on reboot :

touch /.autorelabel
Enable SELinux Relabeling On Reboot In Fedora
Enable SELinux Relabeling On Reboot In Fedora

Step 7 - Finally, exit the single user mode and reboot the Fedora system to normal mode by running the following command:

exit
reboot

Wait for SELinux relabeling process to complete. It will take a few minutes depending upon the filesystem's size and speed of your hard drive.

SELinux Filesystem Relabeling In Progress
SELinux Filesystem Relabeling In Progress

Step 8 - After the filesystem relabeling is completed, you can log in to your Fedora system with new root password.

Login To Fedora As Root User
Login To Fedora As Root User

As you can see, the steps to reset root password in Fedora 36 is fairly easy and exactly same as resetting root password in RHEL and its clones like CentOS, AlmaLinux and Rocky Linux.

You May Also Like

6 comments

Jalal Hajigholamali November 25, 2021 - 11:46 am

Hi,
Thanks a lot
Very useful article

Reply
BillBoss21 December 19, 2021 - 12:46 am

Failed to start Switch Root.

Give root password for maintenance (or press Control-D to continue):

Help me please

Reply
sk December 19, 2021 - 1:31 pm

What does it say when you enter the root user password?

Reply
Ros February 19, 2022 - 3:53 pm

I have the same problem.
It say:

Login incorrect.
Give root password for maintenance
(or press Control-D to continue):

Reply
sk February 19, 2022 - 7:50 pm

Hmmm… I haven’t had this issue in my test machine. I will try with another test machine.

Reply
john May 18, 2022 - 8:14 pm

Another way to change the root passwd or create one when Fedora gives you the option to create one on installation is to open a terminal and enter “sudo passwd root”. You will be asked to give your sudo password and then enter the new root password, and then enter it again. I have used this on several of the latest versions of Fedora, including 36.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

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

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More