CentOS 7 – Reset root pw with SELinux enabled

Posted on Posted in CentOS

I found way too many hits for this process that bounced around depending on whether x or y was set.  Here is the quickest method I tested when SELinux is live:

  1. Boot system and press ‘e’ at grub menu
  2. Find line that begins with linux16 or linuxefi
    1. remove rhgb quiet
    2. append rd.break enforcing=0 to end of that same line
    3. ctrl + x
  3. mount -o remount,rw /sysroot
  4. chroot /sysroot
  5. passwd
    1. enter and confirm new pw
  6. mount -o remount,ro /
  7. exit (exit from chroot env)
  8. exit (exit custom boot and continue)
  9. login as root with new pw
  10. restorecon -v /etc/shadow
  11. ls -Z /etc/shadow
    1. role should now display as shadow instead of unlabeled
  12. setenforce 1
  13. reboot now