Change Forgotten CentOS 7 root password Print

  • 2

  1. Reboot the server from console (you can do that remotely if your server has IPMI capability or you are using KVM like device)
  2. Pay full attention to the GRUB boot prompt telling you to press any key – you have just a few seconds to press any key (If you miss this prompt go back to step 1)
  3. You will see a GRUB boot prompt – press “e” to edit the first boot option.
  4. Find the kernel line (starts with “linux16”), replace ro with rw init=/sysroot/bin/sh.
  5. Press CTRL-X or F10 to boot single user mode.
  6. Access the system with the command: chroot /sysroot.
  7. Run passwd root to change the root password.
  8. Type the password .(you will be asked to reenter the password.)
  9. run the commands below to update SELinux parameterstouch /.autorelabel
  10. Reboot the system reboot -f. and enjoy!!

Was this answer helpful?

« Back