In this article, you will learn how to reset the forgotten root password on Ubuntu 18.04 LTS and Ubuntu 20.04 LTS.
Firstly, you need to either power on or reboot your Ubuntu system. You should get a grub menu as shown below. If you are running your system on VirtualBox, press the ‘SHIFT’ key on the keyboard to bring up the boot menu.

Next, press the 'e'
key to edit the grub parameters. This should display a screen as shown below.

Scroll down until you get to the line that begins with 'linux /boot/vmlinuz'
the entire line is highlighted below.

Narrow down to a section that reads "ro quiet splash $vt_handoff"
.

Replace "ro quiet splash $vt_handoff"
with rw init=/bin/bash
as shown. The aim is to set the root file system with read and write commands denoted by the rw
prefix.

Thereafter, press ctrl + x
or F10
to reboot your system. Your system will boot into a root shell screen as shown below. You can confirm that the root filesystem had read and write access rights by running the command.
# mount | grep -w /
The output in the screenshot below confirms read and write access rights denoted by rw
.

To reset the root password execute the command.
# passwd
Provide a new password and confirm it. Thereafter, you will get a ‘password updated successfully’ notification.

With the root password successfully changed, reboot into your Ubuntu system by running the command.
# exec /sbin/init
Thank you for coming this far. We hope that you can now comfortably reset the forgotten root password on your Ubuntu system from the grub menu.
After the reboot step, the Acer laptop continues to slowly scroll : { 3765. etc nonstop with the first numbers increasing in value? Let it run all night and still the laptop is scrolling. Redid it all after shutting down and restarting, Followed the directions again, and once more it is doing the same thing.
Any ideas? I thought it would finally come to an end – but it sure doesn’t look like it. How long should this part of the process continue? Days?
Thanks much for this article,
I made the mistake of changing the username when installing the virtual machine, so that name was not included in sudoers and I didn’t have the root password. Reboot, reset root PW, visudo, and add the correct user (I use NOPASSWD:ALL since it’s a VM on a laptop just for utility) reboot again, and “all better now.” :-)