How to Reset Forgotten Root Password on Fedora

Help! I’ve forgotten the root password! Even if you’ve forgotten the root password to your Fedora Linux system, it’s pretty easy to recover access to the root account by setting a new password. In this guide, we’ll show you how to set a new password for your root account in a few short steps.

Reset Forgotten root Password on Fedora

1. First, the machine needs to be off. When you boot it up, hold down your Shift key so the GRUB bootloader menu appears. Make sure the first option is highlighted, which probably just says “Fedora (Workstation Edition),” and press e.

Use the edit option in GRUB bootloader

2. Using your arrow keys, scroll down until you find a line that begins with linux. Somewhere in this line, you should see text that says ro, which means read only.

The kernel is mounted as read only (ro) by default

3. Delete the aforementioned text, and replace it with rw (read-write). You’ll also need to append init=/bin/bash to the end of the line.

Configure read and write permissions and a Bash shell

4. After you’ve made that change, press F10, to save it.

5. Your system will load into Fedora already logged into root and with a Bash shell. You can now use the passwd command to set a new password for root.

Setting a new root password with the passwd command

6 Next, execute the following command to trigger relabeling for SELinux. This is a necessary step on Red Hat-based distros like Fedora.

# touch /.autorelabel

7. Once you’re done, execute the following command to reboot your system. Then, you’ll load into Fedora like normal and can use the new password to access root. Subsequent boot ups should also be totally normal.

# exec /sbin/init

That’s all there is to it. You’ve successfully restored root access on your Fedora system under a newly configured password. Note that SELinux relabeling may take some time to complete – you just have to wait this out.

SELinux policy relabel

Leave a Comment

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