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