How To Reset Lost or Forgotten Root Password In Fedora Linux 31

What happens if the system administrator forgets the root password? No worry, this post will demonstrate how to reset a lost or forgotten root password in Fedora Linux 31. You may take a KVM console If your system have a management console connected. Please note that it is better to have physical access to the machine in order to reboot and to access GRUB settings. There are two ways to reset forgotten root password. No worry, this post will demonstrate. You may take aIf your system have a management console connected. Please note that it is better to have physical access to the machine in order to reboot and to accesssettings. There areto reset forgotten root password.

1. Fedora Live Media

2. Rescue Mode

In this guide, we will reset lost or forgotten root password using Rescue Mode.

Also Read: How to reset forgotten root password of RedHat and CentOS 7 Linux

Also Read: Fedora Linux 31 Workstation Installation Steps with Screenshots

Step 1 - Edit the GRUB Menu

Interrupt booting process holding "Shift" key while loading GRUB, if you boot using BIOS. If your system boots using UEFI, press "Esc" key.

Press 'e' when you see the GRUB menu to edit GRUB

Note: You can press "Esc" key any time to exit from while editing

without saving it.

Go to the line starts with "linux16", "linux" or "linuxefi" and add "rw init=/bin/bash" at the end of line after adding space.

Note: Add "plymouth.enable=0" if your disk is encrypted.

Press 'Ctrl+x' or F10 to boot.

Step 3 - change root password

Command prompt will appear after exiting from GRUB editing screen. R

un command

from command prompt to change root password.

It will prompt you to enter the new root password twice.

# passwd

Restore the SELinux context and permissions with below command

# touch /.autorelabel

Reboot the system

# /sbin/reboot -f

Step 5 - SELinux will be relabeling its permissions on the filesystem which may take time to boot. Once it is done, the machine will be ready to accept newly change root password.

Login with newly reset root password.

Note: If the normal user account has sudo rights, 'sudo password' might do the wonder for your.