AlmaLinux is a RedHat-based Linux distribution used for servers as well as desktops. Some users may forget their AlmaLinux root user password after a while. In this case, the only way to recover the root password is to reset it. In this article, we are going to teach you How to Reset Root Password on Almalinux 8.4. You can visit the packages available in Eldernode if you wish to purchase a Linux VPS server.
Table of Contents
How to Reset Root Password on Almalinux 8.4
Prerequisites to Reset Root Password on Almalinux 8.4
In this section, we want to show you how to Reset the Root Password on Almalinux 8.4. The first step to do this is to restart AlmaLinux. When the boot menu appears, you must press the “e” key on your keyboard. As you can see in the image below, this opens the Grub boot editing interface:
In the next step, you need to use the arrow keys. Then you have to add the following line after /swap and before initrd. One thing to keep in mind is that if an rhg line is quiet, delete it right after /swap.
- rd.break enforcing= 0
After completing the above steps, you can now press Ctrl+X to start the startup process. By doing this, you can start the Emergency mode scripting Shell.
Next, you need to create read and write access to the sysroot file system using the following command:
mount -o remount,rw /sysroot
You should now be able to access the Sysroot file in a restricted environment using the following command:
chroot /sysroot
Reset Root Password on Almalinux 8.4
In the previous section, we made the necessary prerequisites to change the root password. Now you can easily reset the password by running the following command:
passwd root
The system will now ask you for a new password. The point to note is that nothing is displayed on the screen when typing the password. You must specify a strong password. This password must be at least 8 digits long, otherwise, it warns that the password is weak. Finally, press the Enter key when done.
Exit Sysroot using the following command:
exit
As you saw a while ago, we changed access from read-only to read/write. Now you need to reset it before leaving the system:
mount -o remount,ro /sysroot
You can exit the current Switch root session and restart the system using the following command:
exit
How to Login root with a new Password
Log in with your new username and password as you view the AlmaLinux sign-in page. Note that after resetting the password, it is best to use the following command to clean the /etc/shadow system passwords that store the system password in an encrypted format. Doing so will remove any remaining input:
restorecon /etc/shadow
Conclusion
If you are locked in the AlmaLinux instance and have lost access to the root account, you will need to boot into single-user mode and reset the root password. In this article, we tried to teach you How to Reset Root Password on Almalinux 8.4.