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.” :-)
Just get onto “Advanced Options for Ubuntu” and from there, we can get onto the root shell.
Yes, it works for me…
Thanks
Thank you for the tutorial. Worked for me.
You are Welcome Akhil. We’re glad that you found this guide helpful.
I have problems after pressing F10. The system boots and prompts “root@(none):/#” but I lost keyboard, so I can’t input anything at all.
The system is up, if I plug/unplug the usb keyboard it’s detected on linux (ubuntu) and shows on the screen. The only thing I guess it may be related to the keyboard, it is a wireless one, so maybe, just maybe, it needs some additional drivers.
I’ll try with a wired and tell you if it works.
If any have a hint, it will be appreciated.
I am not able to reset my password. Can you suggest to me any other options to rest my password?
@Narpat,
What error are you getting while resetting the root password? also what Ubuntu version you are using?
My screen showing the password is updated successfully. But when I log in after reboot, the screen showing an incorrect password. And i am using 20.04 LTS Ubuntu
Maybe you mistyped a character or two. Try the password reset again and write down what it is. Then when you try to log in, you know exactly what to type.
Or you can start using a Password Manager. No matter what you type for a password, the PM will remember for you.
While changing the passwd use below commands,
-> check the username
ls /home
-> now use this username(ubuntu) to change the passwd
passwd ubuntu
enter the new passwd.
And follow the steps from this website to proceed next.
Also, it is written that if running your system on VirtualBox. What if am not what should I do?
Hey Moses, if you are not in a virtualized environment – that is if you are running Ubuntu in a physical or bare metal system – then the grub menu should pop up without any difficulties.
Please for my case after I reboot my machine and press the shift key nothing shows it still boot normally.
Same with me.
Please help me
I followed each and every step but no use and when I try repeating the steps I’m unable to get into the grep menu even pressing of SHIFT button. It’s loading normally I mean directly got into the GUI.
Hey Dev, press the SHIFT key once you see the VirtualBox logo. This should evoke the grub menu on your screen.
Hey Moses, you should press the SHIFT key immediately the VirtualBox log pops up in the event you are using VirtualBox.
Thank you.
A long time ago I know all this :)
I can’t reset my password in ubuntu18.04. I have like that “ro quiet splash acpi_osi= $vt_handoff“.
Not the same with you. So I replace all like that ~
But is still does not work.
I cannot understand why i have “acpi_osi= “.
Thank you for your article!
It seems to me, there is a mistake after “To reset the root password execute the command.” The command “passwd” should be inserted in a string instead of “passed”.
“To reset the root password execute the command.
I think you mean “passwd” and not “passed“. Letters “w” and “e” are next to each other in the keyboard.
@Martins,
Thanks for pointing out, corrected the command in the article…
To reset the root password execute the command.
Don’t you mean:
Finger check – the “e” and “w” keys are next to each other.