Recovering the Root Password (RHEL / CentOS 7)

This guide will provide you with an information on how to reset lost root ( administrator ) password on RHEL / CentOS 7

  • Start or reboot a system to get into the boot menu.
  • Press any key to stop the auto selection of a menu item.
  • Ensure the kernel you intend to boot into is highlighted and press the E key to edit the entry.
  • Navigate to the”linux16″ kernel line and hit the End key to go to the end of the line.
  • Append rd.break to the linux16 kernel line.
  • Hit Ctrl + X to continue.
  • The system boots into an emergency mode that has the /sysroot directory mounted as read only.
  • Mount the /sysroot directory with read and write permissions.
mount -oremount, rw /sysroot
  • Switch into chroot jail and set the /sysroot as the root file system.
chroot /sysroot
  • Reset the root password.
passwd root
  • Cleanup. Make sure that all unlabeled files get relabeled during the boot process for SELinux.
touch /.autorelabel 
  • Exit chroot jail.
exit
  • Exit the initramfs debug shell.
exit

Mohammed has written 29 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>