Home Fedora How To Reset Root Password In Fedora 35

How To Reset Root Password In Fedora 35

Reset Forgotten Root Password In Fedora

By sk
484 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.

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 35
Grub menu in Fedora 35

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

Find ro kernel parameter in Grub
Find ro kernel parameter in Grub

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 file system in read, write mode in Fedora
Mount root file system in read, write mode in Fedora

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 35 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

1 comment

Jalal Hajigholamali November 25, 2021 - 11:46 am

Hi,
Thanks a lot
Very useful article

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. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More