Skip to main content

RESETTING ROOT PASSWORD IN RHEL/CENTOS 7

First during booting at the grub boot loader select the kernel and press ‘e’ to edit



On the next screen, at the end of line bigining with linux 16 type
rd.break console=tty1




Press cntrl + x to reboot
Now the root file system is mounted as read only to /sysroot.We have to make it read write.
mount -o remount,rw /sysroot
Once the file system has been remounted, change into a chroot jail so that /sysroot is used as the root of the file system. This is required so that any further commands we run will be in regards to /sysroot. This is done by running ‘
chroot /sysroot
Now set password for root using
#passwd root
Now if we are not running selinux,we can reboot at this point.If we are running selinux we have to fix context in /etc/shadow
For that type command #touch ./autorelabel
Now for reboot type exit