Forgetting your root password on Fedora isn’t the end of the world. Fedora makes it possible to reset it—though it does require a little know-how and physical access to your machine. Whether you’re running Fedora 39, 38, 37, or 36, the steps are nearly identical. Here’s how to reset your root password safely.
What You’ll Need
- Physical access to the machine
- A keyboard connected (if it’s a server or VM, access to the console)
- A few minutes of downtime
Step-by-Step: Resetting the Root Password
1. Reboot Into GRUB Menu
Restart your system. When you see the GRUB boot menu, act fast:
- Press
e
on the default Fedora kernel entry to edit it.
2. Modify Kernel Parameters
You’ll see a bunch of text. Find the line that starts with:
linux /vmlinuz...
Go to the end of that line (use arrow keys) and add the following:
rd.break
This tells Fedora to break into an emergency shell before mounting the root filesystem.
Now press Ctrl + X
to boot with these parameters.
3. Remount the Filesystem
Once you drop to the emergency prompt:
switch_root:/# mount -o remount,rw /sysroot
Then access the root filesystem:
switch_root:/# chroot /sysroot
4. Reset the Root Password
Now set your new root password:
sh-5.1# passwd
Type the new password twice when prompted.
5. Relabel SELinux Contexts (Important!)
This step ensures SELinux doesn’t block your login:
sh-5.1# touch /.autorelabel
6. Exit and Reboot
Type:
exit
reboot
Your system will reboot. The SELinux relabeling may take a few minutes. Once it finishes, you can log in as root with your new password.
A Few Tips
- This method only works if you have physical or direct console access.
- If your system is encrypted, you’ll still need the decryption passphrase at boot.
- For systems where GRUB is password-protected, this process won’t work unless you know the GRUB password.
That’s It
You’re back in business. Fedora’s recovery tools are solid, and with a few steps, you can reset your root password without needing to reinstall or recover from backup.
Leave a Reply