User Tools

Site Tools


classnotes:rh134:reset-root

Reset the Root Password

To access that root shell, follow these steps:

Reboot the system.

  • Interrupt the boot-loader countdown by pressing any key, except Enter.
  • Move the cursor to the rescue kernel entry to boot (the entry with the rescue word in its name).
  • Press e to edit the selected entry.
  • Move the cursor to the kernel command line (the line that starts with linux).
  • Append rd.break. With that option, the system breaks just before the system hands control from the initramfs image to the actual system.
  • Press Ctrl+x to boot with the changes.
  • Press Enter to perform maintenance when prompted.

To reset password you need to:

  • Remount /sysroot as read/write.
    mount -o remount,rw /sysroot 
  • Switch into a chroot jail, where /sysroot is treated as the root of the file-system tree.
    chroot /sysroot 
  • Set a new root password.
     passwd root 
  • Ensure that all unlabeled files, including /etc/shadow at this point, get relabeled during boot.
     touch ./autorelabel 
  • type exit twice

this can take a while other option is to use

load_policy -i

this causes Selinux policy to be loaded and now we can use Selinux commands

 restorerecon -FvR /etc/shadow

This relabels /etc/shadow correctly. You can exit the server and reboot as it will start to generate errors

when making changes to grub you need to edit the /etc/default/grub once you are done you need to regenerate the grub config file

 grub2-mkconfig -o /boot/grub2/grub.cfg 
classnotes/rh134/reset-root.txt · Last modified: by 127.0.0.1