How to reset root password of Ubuntu 20.04 LTS focal fossa

If you have recently installed Ubuntu 20.04 LTS focal fossa but forget the root password then here is the solution to reset it using the command line terminal.

Officially, Ubuntu has launched its long-term 2020 version which is 20.04 LTS, however, the beta version was around for a very long time. Thus, if you are facing a situation in which after setting a root password, somehow you forget it and also don’t have any other non-root account with sudoaccess. Then don’t worry you have to just go through a little technical stuff and you could reset the root password.


Nothing much just the system where you have installed your Ubuntu 20.04 with access to restart the machine to drop yourself in the GRUB menu.

Steps to reset Ubuntu 20.04 root password

In this tutorial, we will learn the steps which we need to follow to reset the password not only for the root user but for other users as well, using the GRUB. Along with this, will also see a way to get the command line terminal or shell access with the root account but without supplying any password.

1. Open Ubuntu 20.04 Grub menu

To get the advance options, first, we get the Grab menu, for that reboot your system. While booting up Ubuntu 20.04, immediately press and hold the SHIFT key. This will show the GNU GRUB screen with three or more options.

2. Edit the Grub command before booting

Now, before booting the system we have to edit something, for that press the ‘e‘ key on your keyboard. This will let you edit the Grub’s boot prompt.

Edit the GRUB commands before boot
Edit the GRUB commands before boot

Now, on the screen, you will see a few pre-configured commands, use the navigation arrow keys and go down to find the text “ro  quiet splash $vt_handoff

Command to replace
Quiet splash to replace

Now delete and replace that with, rw init=/bin/bash as shown in the below screenshot. Here we are pointing the kernel to run /bin/bash (which is a shell). Where rwtells it to boot with hard disk read and write permissions which would be otherwise in read-only mode and won’t let us write or change any file or code saved on the disk. Basically, init is the first process that fires up in Linux and is usually found at /bin/init or /sbin/init.

boot kernel with shell
boot kernel with shell

Note: Don’t worry this is not a permanent change in the grub, just a temporary one to recover the root or any other account without formatting the whole system.

3. Got access to root shell without password

Once you boot the Ubuntu 20.04 after altering the code as mentioned in the above step you will see, you gained Shell access along with root privileges without entering any password. From here you can execute the root commands with admin rights.

Now, don’t think it is a loophole or bug of Ubuntu, basically, it is a flexible feature that is provided in Linux to help system administrators to recover the system in case there is some misconfiguration happening or to change the forgotten password.  However, we can restrict access to this feature to increase the security and thwart some unwanted access to our system boot.

access to root shell without password
access to root shell without password

To make sure we got the boot partition access as root with a read and write access use this command:

mount | grep -w /

The output will be like this:

/dev/sda5 on type ext4 (rw,realtime)

The rw in the above output shows, we have got the real-time read and write authorization of the partition.

4. Reset the Root & user Password

Finally, we have everything and now just need to change the old root password without remembering that. Simply run:


The above single command will ask you to enter the new password twice after which it will successfully change and reset your forgotten password for the root.

Well, also at the same time and place we can change the password of any specific user. For example, here we have a non-root user h2smedia, thus the command will be like this:

passwd username

Replace the username with yours. If we go according to the above command, then in our case it was:

passwd h2smedia

Reset Ubuntu 20.04 user and root password

5. Finally, reboot your system

Thus, we have successfully set everything that we want, and now it’s time to reboot the system to use it in the normal GUI or CLI mode.

Type this and hit the Enter button.

exec /sbin/init

So, this was the quick tutorial on the password forget problem in Ubuntu 20.04, if you are facing any problems while performing the above steps, please let’s know.

Other Articles:

1 thought on “How to reset root password of Ubuntu 20.04 LTS focal fossa”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.