Ubuntu

How to reset the root password on Ubuntu 22.04 if forgotten

In Ubuntu, the root password is the real key to success for the terminal enthusiasts. The root user account helps to access or manipulate the settings of all the Ubuntu programs/applications. The root password is required to login as a root user.

The frequent Ubuntu users may have the root password on tips. However, there is a possibility of forgetting the root password. In such a case, the user must reset the root password to login as a root user.

This article intends to provide a solution to reset the root password on Ubuntu 22.04. What if the password is forgotten?

How to reset the root password on Ubuntu 22.04

The GRUB boot loader acts as an escape plan to switch to a new root password. GRUB (GRand Unified Boot Loader) boot loader starts up from the BIOS and leads up to load the installed operating system. The GRUB boot loader will be used to reset the root password.

Step 1: Start/restart your Ubuntu system and enter the shift-key/esc-key to enter the GRUB menu. The following interface is observed.

Text, timeline Description automatically generated

Choose the first option “Ubuntu” and enter inside it using the “e” key to edit a few settings.

Step 2: The following interrace will appear where you have to change the part of a line marked in the following screenshot. Use the arrow key to scroll down the file until you find the line.

Text Description automatically generated

Replace the line “quiet splash $vt_handoff” to “init=/bin/bash“. Moreover, change the permission from “ro” to “rw” as well.

Text Description automatically generated

After that, press CTRL+X or F10 to boot with the above written settings.

Step 3: A command line interface will appear soon (as a root user) as can be seen in the following image.

Type the following command and hit enter.

$ passwd

A screenshot of a computer Description automatically generated with medium confidence

Upon successful execution of the command, you need to enter a new password. For confirmation, it will ask to enter the password again. After doing so, the password will be updated.

Conclusion

The root account is just like a catalyst in the routine life of a Linux user. The root account is secured with a password known as root password. In this how-to post, we have provided the method to reset the root password if forgotten. The GRUB boot loader is the key player in resetting the root password. We have provided a set of sequential steps to access and reset the root password using GRUB boot loader.

About the author

Adnan Shabbir