Thursday, 26 January 2017

RECOVER ROOT USER PASSWORD - LINUX

*************************************************************************
How to reset the root password on RHEL 7 ?
*************************************************************************

Here we will see that how we can recover the lost root password on RHEL 7.

1. Reboot the system .

left hand >> with fingers >> one you have hold ctrl button and other one is alt button press together and release it >> and select the mouse on the screen and press e button when you see kernel


2. In the grub menu, press escape key to prevent the system from booting.
Edit the grub menu by pressing “e” .

3. Press the arrow keys to get the “linux16” line and press “end” key.
This will take you to the end of the line.
Here add "rd.break" or "rd.break  console=tty1"  and
Press control-x to boot the system.

4. You will get the “switch-root” prompt like below.

5. When you boot the system using “rd.break”,
system will be directly mounted on /sysroot in read-only mode.
Let me remount it in read/write mode.

switch_root:/# mount -o remount,rw /sysroot

6. Switch into a chroot jail, where /sysroot is treated as the root of the filesystem tree.

switch_root:/# chroot /sysroot

7. Set the new root password. (please update the CMDB immediately !)

sh-4.2# passwd root
New password:
Retype new password:
passwd:all authentication tokens updated successfully.

8.By default, SE-Linux will be enabled on RHEL7.
So create a blank file with the a name of “.autorelabel” under root.

sh-4.2# touch /.autorelabel

9. Exit from the chroot jail and exit from the initramfs.

10. System will reboot and perform a full SELinux relabel, then  reboot again.

11. once the system is rebooted,
you will be able to login with new root password which you have set it .

************************* Keshav Kummari *****************************

No comments:

Post a Comment