To start the system in a single-user mode, it is necessary to edit the boot line. To do this, use the keys ↓ and ↑to navigate through the menu, select your boot line (often it is "* Ubuntu"), and press the "e" key to access the boot mode editing options.
Find the line that starts with "linux /boot ". At the end of the line, change the "ro" parameter to "rw", add the parameter "init=/bin/bash" after a space. Now everything is ready to start the system in the single-user mode. Press "CTRL+X" or "F10" to start the system.
As a result, you get a console where you should run the command:
passwd root
or
passwd ubuntu
Enter the new root password twice.
The root password is now changed. Save the changes and restart.
sync
reboot –f