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.

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

Enter GRUB Bootloader

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

Find the kernel line (starts with “linux”), change,

ro 

to

rw init=/sysroot/bin/sh

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

Enter the system with the command,

chroot /sysroot

Run passwd to change the root password.

passwd 

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

Update selinux information.

touch /.autorelabel

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.

Related posts

How to Create Remote Desktop Gateway via Apache Guacamole on AlmaLinux 9

How to Secure Nginx with Let’s Encrypt on AlmaLinux 9

How to Install Glances on AlmaLinux 8