How to Reset Forgotten Root Password in Ubuntu

User roles on a Linux operating system are hierarchy-based. The root user sits on the iron throne and is able to control the actions of all other users. It is the administrative/authentication power of this root user that controls the actions of any other user with access to the Linux system.

[ You might also like: How to Create a Sudo User in Ubuntu Linux ]

The root user can override or change normal users’ actions and permissions. Therefore, things like system updates, app installation & configuration, and general system configuration might sometimes require the approval of the root user password.

Root Authentication Required
Root Authentication Required

So what happens when a normal Linux user or system administrator forgets the system’s root password? Please note that changing the root password is different from resetting the root password.

During such incidences, you might think you have reached rock bottom and even think about re-installing your Ubuntu system. However, this article guide is here to prescribe the ultimate pain killer for this headache.

Reset Forgotten Root Password in Ubuntu

The solution to this problem entails restarting your Ubuntu system, accessing the Grub boot loader menu, and booting into the Ubuntu system from the recovery mode.

Therefore, restart your Ubuntu-powered machine, and once the computer’s screen dims, continuously press the keyboard’s [Esc] or [Shift] keys until you are redirected to a Grub menu screen.

Ubuntu Grub Menu
Ubuntu Grub Menu

From the provided GNU Grub Menu screen capture, you will see a number of menu options. Use the keyboard’s [up] and [down] arrow keys to navigate to the Advanced Options for Ubuntu segment.

Advanced Options for Ubuntu
Advanced Options for Ubuntu

Hit [Enter] on your keyboard and you will be redirected to another Grub window and here choose the menu option that will direct you to Ubuntu (recovery mode).

Choose Ubuntu Recovery Mode
Choose Ubuntu Recovery Mode

Wait a few seconds for the dashing black screen to complete its execution. Another display screen with several menu options will appear.

Ubuntu Recovery Menu
Ubuntu Recovery Menu

Navigate to the menu option root Drop to root shell prompt and hit [Enter] on your keyboard.

Ubuntu Root Shell Prompt
Ubuntu Root Shell Prompt

At the bottom of this display window, you will be presented with a command-line interface with direct access to the root shell prompt.

Ubuntu Maintenance
Ubuntu Maintenance

The next step is to remount the root filesystem partition (/) with write access. Its default access partition is read-only.

# mount -rw -o remount /
Ubuntu Mount Root Filesystem
Ubuntu Mount Root Filesystem

From here, you can now comfortably reset the root password and even username if you wish. Before you can reset the root password, you need to be able to identify the user associated with it.

# ls /home
Identify Ubuntu User
Identify Ubuntu User

After you identify the root user, use the following command syntax to reset the associated root password:

# passwd username

We can now change the root password by referencing the above syntax.

You will be prompted twice to enter and re-confirm the new root password you wish to use.

Reset Ubuntu Root Password
Reset Ubuntu Root Password

From here, you will have achieved the ultimate hack into resetting the root user password on your Ubuntu system.

Key in exit on the console and hit [Enter] on your keyboard. You will again find yourself on the Recovery Menu window. Choose the menu option to Resume normal boot.

Resume Ubuntu Normal Boot
Resume Ubuntu Normal Boot

Ignore any graphics mode compatibility warning as a complete system reboot will fix it.

Exit Ubuntu Recovery Menu
Exit Ubuntu Recovery Menu

Based on the root password you set, you should be able to comfortably re-enter your Ubuntu system as an admin/root user.

Ubuntu User Login
Ubuntu User Login

With this article guide, you do not have to worry about losing control of your root privileges on an Ubuntu system as you can easily regain it from the article’s simplified step-by-step instructions.

4 thoughts on “How to Reset Forgotten Root Password in Ubuntu”

    • Hi Paul,

      Maybe you could provide screenshots of the steps you followed? Also which Ubuntu version are you using? Is it 20.04 LTS? The latest stable version?

      Regards.

      Reply
    • Hi Jurgen,

      The best preventive measure against such a hack scenario is to encrypt your entire drive or filesystem folders and directories that hold critical data. This way, none of your data gets compromised.

      Regards!

      Reply

Got something to say? Join the discussion.