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

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

by tuanlp

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

You may also like