Recover Root User Password In Linux

Losing a root user password may be a worst situation when we’ve to perform some kind of administrative task and all of a sudden, we lost the root password and during that time any admin can be scared and their objective is to recover the lost root user’s password as quickly as possible and recovering a root’s password might look frightening but it’s not that much of tedious activity. From RHEL 7 recovering a root user’s password is very easy and we’ve to perform only few steps to recover it.

 STEP 1: At a very first step we’ve to reboot the server



STEP 2: After reboot, As soon as the bootloader comes up.select and kernel and press ‘e’ and this will take us into the grub boot loader.


STEP 3: Search the line that starts with ‘linux16’ for RHEL/Oracle Linux and add ‘rd.break’ in the end of the line

 For RHEL/CentOS 7, the line starts with 'linux16'.

For RHEL/Centos 8x, and Fedora the line starts with 'linux'.



NOTE : The “\” in the screenshot means a new line added automatically by grub we only need to type rd.break

STEP 4:  type CTRL +X to run the edited boot loader script and a switch_root:/# prompt will come which means a rescue prompt


STEP 5: remount the root partition in read-write mode so that we can run commands. Enter the following command and press ENTER

mount -o remount rw /sysroot



STEP 6: Type below command and press ENTER this will change us into /sysroot directory and make that path for executing commands.

chroot /sysroot 

STEP 7: Now simply change the passwd using passwd command


STEP 8: Type exit to leave the chroot environment and execute reboot command to reboot the server.
















Post a Comment

Previous Post Next Post