"This guide explains how to reset and change the root password by editing the GRUB menu during system startup. Follow these steps:
-
When the PC starts, press
e
to edit the GRUB menu. -
Find the keyword
ro
(read-only) and replace it withrw
(read-write): -
Add
init=/sysroot/sbin/sh
at the end of the line.-
This enables you to access the root shell
-
Press
Ctrl + X
to continue the boot process. -
Example line:
-
load_video
set gfxpayload=keep
insmod gzio
linux ($root)/vmlinuz-5.14.0-522.e19.x86_64 root=UUID=81745846-b7a0-43a5-9e a5-eeb05633f54f `ro` crashkernel=1G-4G:192M, 4G-64G:256M,64G-:512M resume UUIDS
=4057a1e9-73f4-42e8-82cb-bf7b380f401b rhgb quiet
initrd ($root)/initramfs-5.14.0-522.e19.x86_64.img $tuned_initrd
Minimum Emacs-like screen editing is supported. TAB lists completions. Press Ctrl-x or F10 to boot, Ctrl-c or F2 for a command-line or ESC to discard edits and return to the GRUB menu
- Modify it to:
load_video
set gfxpayload=keep
insmod gzio
linux ($root)/vmlinuz-5.14.0-522.e19.x86_64 root=UUID=81745846-b7a0-43a5-9e a5-eeb05633f54f `rw init=/sysroot/sbin/sh` crashkernel=1G-4G:192M, 4G-64G:256M,64G-:512M resume UUIDS
=4057a1e9-73f4-42e8-82cb-bf7b380f401b rhgb quiet
initrd ($root)/initramfs-5.14.0-522.e19.x86_64.img $tuned_initrd
Minimum Emacs-like screen editing is supported. TAB lists completions. Press Ctrl-x or F10 to boot, Ctrl-c or F2 for a command-line or ESC to discard edits and return to the GRUB menu
-
Change the default root path to access all binaries:
- Run the following command:
chroot /sysroot/
- Run the following command:
-
Update the root password:
- To change the root password, run:
passwd
- To change the root password, run:
-
(OPTIONAL) If SELinux is enabled, create an autorelabel file:
- This step ensures SELinux relabels the files on the next boot:
touch /.autorelabel
- This step ensures SELinux relabels the files on the next boot:
-
Reboot the system:
- Finally, reboot the system with the following command:
reboot -f
- Finally, reboot the system with the following command: