How to Reset Forgotten Root Password in Fedora

The only way any Linux user can boldly claim to have full control of their operating system environment is if they can be identified as root or Sudoer users. A normal Linux user is identified by running the following command on the Linux OS terminal:

$ whoami

This command should output a normal system username on your Linux OS.

Check Current Logged User
Check Current Logged User

As for a Linux user with root privileges, the implementation of the above command can be modified in the following manner:

$ sudo whoami

The expected output from this command’s execution should be the root.

Check User Privileges
Check User Privileges

To be recognized as a root user in Linux, you need to have the root user credentials as demonstrated by the execution of the above sudo preceded command. To switch to the root user account where you will no longer need to execute your user-privileged commands with a preceding sudo, run the following command:

$ sudo -s 

When in the root user account, user-privileged command executions like system updates can be executed in the following manner.

# apt update

A non-root user will need to run the above command in the following manner:

$ sudo apt update 

In Fedora Linux distribution, before you even get to use this operating system, its installation procedure allows the OS installer to associate the currently created user with root user privileges or alternatively create a root user account.

However, due to some unavoidable reasons, you may end up forgetting your root user credentials. Therefore, it will be close to impossible to perform some OS installations, updates, and configurations that require root user access.

There are two alternatives to this issue, you will either re-install your Fedora Linux distribution to set a new root user password or continue with this article guide to solve this issue.

Resetting Forgotten Root Password In Fedora

Firstly, the Fedora Linux machine in question needs to be powered off. After the Fedora Linux system is completely powered off, we will need to restart it.

While it is restarting, be prompt to press the [Esc] keyboard key or any other associated keyboard key that will redirect you to the Grub bootloader menu similar to the one below.

Fedora Grub Boot Menu
Fedora Grub Boot Menu

From this Grub bootloader menu, notice the wordings Press ‘e’ to edit the selected item at the bottom of the display screen.

Edit Grub Boot Menu
Edit Grub Boot Menu

Proceed and press [e] from your keyboard. You will be presented with the following new screen grab and here notice the highlighted line-entry ro which stands for read-only and quiet.

Fedora Kernel Paramaters
Fedora Kernel Parameters

Navigate to this line entry with the keyboard navigation keys and replace it with rw which implies read-write and init=/bin/bash as shown.

Modify Kernel Paramaters
Modify Kernel Parameters

After you have successfully made these two changes, press the keyboard [F10] key to implement the changes. You will then be taken to a bash prompt that resembles the following screen grab.

Fedora Bash Prompt
Fedora Bash Prompt

Now use the Linux passwd command to set a new root user password for Fedora Linux.

# passwd
Reset Forgotten Fedora Root Password
Reset Forgotten Fedora Root Password

Since Fedora Linux is a Red Hat distribution, we need to trigger SELinux relabeling with the following command.

# touch /.autorelabel 

Finally, reboot your Fedora Linux system by running the following command.

# exec /sbin/init

Due to SELinux relabeling, the above command may take some time to complete its execution.

SELinux Relabelling Fedora
SELinux Relabelling Fedora

Log in with your Fedora Linux system and try switching to the root user account from the command line.

$ su – root
# whoami
Confirm User Privileges
Confirm User Privileges

You no longer have to worry about forgetting your Fedora Linux root password. Your comments and feedback are always appreciated.

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.