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
- Restart your Linux system.
- When the GRUB menu appears, select the boot entry you want to modify and press
eto edit. - Find the line that starts with
linuxorlinux16. - At the end of this line, add
rd.break. - Press
Ctrl + XorF10to boot with the modified entry. - Once the system boots into a shell, remount the root filesystem in read-write mode by running:
mount -o remount rw /sysroot - Change the root directory to the sysroot:
chroot /sysroot - Change the root password using the
passwdcommand:passwd - Enter the new password and confirm it.
-
If SElinux is enabled, you may need to relabel the filesystem. Create an empty file to trigger the relabeling:
touch /.autorelabel - Exit the chroot environment:
exit - Exit the shell environment:
exit - After Machine Reboot the system will relabel the filesystem and you will be able to login with the new root password.
Important Notes
- Ensure you have physical access to the machine to perform these steps.
- Changing the root password without authorization may violate security policies.