Boot Into GRUB menu
The first step is to reboot into the GRUB menu. If Ubuntu 18.04 Bionic Beaver is the only operating system installed you need to keep pressing SHIFT for the GRUB menu to show up.
Edit Grub Menu
Using arrows select the Ubuntu menu or the menu you use to boot your system and hit the e key. This will allow you to edit the menu:
Navigate down with the arrow-down key until you can see a line ending with:
ro quiet splash $vt_handoff
Using your keyboard replace the following keywords.
FROM: r o quiet splash $vt_handoff TO: rw init=/bin/bash
Once you have made the change press F10 or CTRL + x to perform boot into a single mode.
Confirm that your system partition is mounted as read/write (rw):
# mount | grep -w /
If all good, reset your root password with the passwd command:
Your root password is now reset. Reboot your system:
# exec /sbin/init