How to Reset Root Password Via Single User Mode on AlmaLinux 8

This article will explain how to reset your root password in case you've forgotten or lost access to the AlmaLinux system.

For this, you will need direct access to the system. In our case, it is a Virtual Server, so we will be using the VNC feature from CrownPanel.

You will need to enter the GRUB bootloader to perform the password reset.

Enter GRUB Bootloader

  • Open the VNC console by navigating to the "VNC" Tab and by clicking on the "Launch VNC" button.
  • Reboot the machine by clicking on the "Send Ctrl-Alt-Del" present on the top right corner of the window.
  • As soon as the boot process starts, press the ESC key to bring up the GRUB Bootloader.
  • You will see a GRUB bootloader screen - press "e" to edit the first boot option (If you do not see the GRUB screen, you may need to press any key to bring it up before the machine boots).

images

Find the kernel line (starts with "linux"), change,

ro 

to

rw init=/sysroot/bin/sh

images

Press CTRL-X or F10 to boot single-user mode.

Enter the system with the command,

chroot /sysroot

images

Run passwd to change the root password.

passwd 

images

Note: stating that the password entered will not be visible.

Update selinux information.

touch /.autorelabel

images

We will exit the chroot and then reboot the system.

exit
reboot

After this, you should now be able to login/access your system with the newly set password.