Skip to content

Reset the root password: Fedora Server

This tutorial explains how to recover the root password on a Fedora Server.

During the Linux server boot, a boot screen like the one below will appear:

image-1719319990630.png

Press the “e” key to open the boot configuration edit mode as shown below:

image-1719320093869.png

Find the line that starts with “linux” or “linux16” or “linuxefi” and at the end add “rw init=/bin/bash” as in the example below:

image-1719320698513.png

Press CTRL + X to boot Linux with the new settings. The following screen should appear:

image-1719320807739.png

Enter the commands below to change the password:

Terminal window
passwd

Restore SELinux permissions with the following command:

Terminal window
/bin/sed -i s/"SELINUX=enforcing"/"SELINUX=permissive"/ /etc/selinux/config
touch /.autorelabel

Then, reboot the server with the command below:

Terminal window
/sbin/reboot -r

After rebooting the server, log in as root and re-enable SELinux with the commands below:

Terminal window
sed -i s/"SELINUX=permissive"/"SELINUX=enforcing"/ /etc/selinux/config
setenforce enforcing