1. Restart the computer and press the "E" key when the operating system startup menu appears to enter the GRUB boot menu interface.
2. Find the line starting with "linux /vmlinuz-", add "rw single init=/bin/bash" at the end (move the cursor to the end of this line or press the "Ctrl+E" key), and press Ctrl when finished +X key combination or F10 to restart.
3. Use passwd to change the password of root or an existing user.
4. Then press Ctrl+Alt+Del or reboot -f to restart the computer.
reference