Enter single user mode:
grub
After entering the startup screen, type “e”, move the cursor to the kernel… line, type “e” again, add a space single at the end of the kernel line, and press Enter
Type “b” to start the system and enter the single user mode.
At this time, you can use the passwd command to change the password.
passwd root
Reboot after the change.
lilo
Enter lilo command line mode and type linux single to enter single user mode.
passwd…
If you set a password for grub/lilo, you must remember it. If you forget the password for grub/lilo, you have to use rescue mode.