How to reset Root user password from boot on Oracle Linux 8.5

To Reset Root Password From Boot On Oracle Linux 8.5

Introduction:

Grub is the boot menu. It allows you to choose between multiple operating systems if you have more than one installed. Additionally, Grub can be used for troubleshooting. It can be used to modify boot arguments or to boot from an older kernel. In this tutorial, I'll show you how to reset the root password in Oracle Linux 8.5.

Procedure:

Step 1: Restart the linux machine by using the below command

[root@localhost linux]# init 6

Step 2: While turning on the power button, at the grub boot menu press the

“e” key to edit the first boot entry as shown in the below image

Step 3: From the grub options, go to the line that starts with “ linux” as shown in the below image

Step 4: you have to go the end of the line and type “ rd.break” and then press ctrl+x as shown in the below image

Step 5: Now the initrampfs prompt with a root shell will appear at this stage, the root file system is mounted in read only mode to /sysroot and it must be remounted with read/write (rw) permission, so enter “ mount -o remount,rw /sysroot” as shown in the below image

Step 6: once the file system is remounted, change it to chroot jail so that /sysroot is used as the root of the file system.this can be done by running “ chroot /sysroot”

From here the root password can be reset with “ passwd” command as shown in the below image

Step 7: Now we can reboot but, as centos 7 uses SELINUX enforcing mode by default we have to fix the context of the /etc/shadow file so create “ touch /.autorelabel” as shown in the below image

Step 8: Now Select Not listed and Enter username as root and Enter the password as shown in the below image

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to reset root password from boot on oracle linux 8.5 on Oracle Linux 8.5. Your feedback is much welcome.

FAQ
Q
How does Linux encrypt passwords?
A
Most Unicies (and Linux is no exception) primarily use a one-way encryption algorithm, called DES (Data Encryption Standard) to encrypt your passwords. This encrypted password is then stored in (typically) /etc/passwd (or less commonly) /etc/shadow.
Q
How do encrypt and decrypt passwords in Linux?
A
To encrypt and decrypt files with a password, use gpg command. It is an encryption and signing tool for Linux and UNIX-like operating systems such as FreeBSD, Solaris, macOS, and others.
Q
What is sudo su root?
A
sudo su - The sudo command allows you to run programs as another user, by default the root user
Q
Where is the user password stored?
A
The /etc/passwd file, which contains information about all users, including their encrypted password, is readable by all users
Q
How do I change the admin password in Linux?
A
Type the command 'passwd' and press 'Enter. ' You should then see the message: 'Changing password for user root. ' Enter the new password when prompted and re-enter it at the prompt 'Retype new password.