0

Reset root password on RHEL/CentOS 7

much have changed since 4/5/6 days since RHEL/CentOS7 uses grub2 to boot. root password recovery is now very different than before.

  • start/reboot the system and on the GRUB2 boot screen press the e key for edit.
  • scroll down to the linux* line (could be linux/linux16/linuxefi) and remove rhgb and quiet and add init=/bin/sh to the end of the line. For some virtual hosts you might have to use rb.break instead of init=/bin/sh.
  • Press CTRL-X to boot the system and it a shell prompt will be presented.
  • Once booted the / filesystem will be in read only mode please issue mount and verify it and issue the following to make it read/writeable. mount -o remount,rw /
  • Run the passwd command to reset the password
  • Touch /.autorelabel to make sure that SELinux context of the files modified is restored.
  • run exec /sbin/init to boot into normal mode or exec /sbin/reboot to reboot the server.
  • jlim0930

    Leave a Reply

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

    This site uses Akismet to reduce spam. Learn how your comment data is processed.