Change Linux Root Password Using GRUB Mode

Follow these steps to reset the root password on a Linux system using GRUB mode:

Step-by-Step Process

  1. Restart your Linux system.
  2. When the GRUB menu appears, select the boot entry you want to modify and press e to edit.
  3. Find the line that starts with linux or linux16.
  4. At the end of this line, add rd.break.
  5. Press Ctrl + X or F10 to boot with the modified entry.
  6. Once the system boots into a shell, remount the root filesystem in read-write mode by running:
    mount -o remount rw /sysroot 
  7. Change the root directory to the sysroot:
    chroot /sysroot
  8. Change the root password using the passwd command:
    passwd
  9. Enter the new password and confirm it.
  10. If SElinux is enabled, you may need to relabel the filesystem. Create an empty file to trigger the relabeling:
    touch /.autorelabel
  11. Exit the chroot environment:
    exit
  12. Exit the shell environment:
    exit
  13. After Machine Reboot the system will relabel the filesystem and you will be able to login with the new root password.

Important Notes