Discuss how to recover the root password of Linux without using any external media. The version of Linux we are working with is CentOS version 8.2. Still, the procedures we will see can work with any Linux distro and many others. You may find that it doesn’t work with some Debian-based distro.
To do this exercise, you should have the following requisites Prerequisites −
Willingness to work in the Linux command line environment.
Physical access to the Linux server(it cannot do this across a network).
Procedures to follow to change the root password
Restart the computer and interrupt the boot process at the grub screen by pressing the shift key, just a caution on this you’ve got to be ready to move fast when this happens, as you will see when you will practically do it.
Highlight the normal boot entry or OS-name entry and press e to open grub parameters.
Using arrow keys, move down to the line starting with “ Linux /boot/vmlinuz, “ where you need to replace “ro quiet splash $vt_handoff” with “rw init=/bin/bash.”
Pressing CTRL + X will restart the system with changes just made. It will start the system and take you directly to the root shell.
Now type this command to change the password of the root.
$ passwd root
If you are getting the message “ password updated successfully, “ That’s it. The password of the root user has been changed.
Now restart your system by typing this command.
This method works with almost all Linux-based systems. In case if this method doesn’t work, you can try booting from bootable media.
In this tutorial, we discussed recovering root passwords by interrupting grub and changing startup configuration. We do not need any external media in this method, But you should have physical access to the system. If this method doesn’t work, then you have to use a bootable drive.