How to Reset Forgotten Root Password in Ubuntu 24.04

On Linux-based systems, the root account holds the highest level of authority in the user role hierarchy. The root user has complete control over the system, including the ability to modify and override other users' permissions. Typically, users must have the root user's authorization to make any system changes. In Ubuntu systems, the root account is initially disabled by default. However, users can still make necessary changes if they have access to the root password. The issue arises when the root password is forgotten. In this article, I will guide you through the process of resetting the root password on an Ubuntu 24.04 system by altering the Grub boot loader configuration and booting Ubuntu into rescue mode.

Changing the root password

To change the root password in your system, open up the terminal window by using the Ctl+Alt+T shortcut. You can also access the terminal window by going to the ApplicationsTerminal of the system. Now to change the root password, type the following window in the terminal window.

$ sudo passwd root

The system will then prompt the users to enter the new password that they want to set up. After that when you press the <enter> key, the system will again prompt the user to type the new password once again in the Retype new password field.

Enter password

When you will press the <enter> key from the keyboard, the password will then be updated successfully.

Password changed successfully

Resetting the root password

When users have forgotten their root password, they need to enter the user's password.

Step 1: Booting to Recovery

To begin with this method, users need to restart their system. Press the <shift> key from your keyboard as soon as the splash screen appears. The GNU GRUB screen will appear as displayed below:

Grub Boot screen

This is the boot menu for Ubuntu that displays different kernel versions and different options. Select the option Ubuntu by pressing the <enter> key. When you select Ubuntu, you need to press the “e” key to open up the grub parameters that are to be edited.

Boot parameters

Step 2: Changing the configurations

After that, use the arrow keys again and scroll down to the bottom line that begins with the “Linux/boot/vmlinuz” keyword.

Change configuration

From the above-highlighted line, you need to replace “ro quiet splash $vt_handoff” word with “rw init=/bin/bash”.

Boot into bash shell

Step 3: Rebooting the system

The next step is to reboot your system. This will be done by using Ctrl + X or the F10 key. It will help you reboot the system along with the updates you made. The system will restart, and then you will be landed in your root shell. The shell will appear only once, and in the future, it will appear normally.

To see if your root file system has been mounted correctly, append the following command to the shell.

$ mount | grep -w /

Search mountpoint

Step 4: Changing the root password

To change the root password, type the following password command:

$ passwd

Set password

After that, the system will prompt you to type the new password and once you have pressed the enter key, it will again ask you to re-type the password.

Retype password

Once the password is updated, a success message will appear on the screen.

Password updated successfully

The password is now changed/rest successfully. To confirm the updates, you can restart your system.

Conclusion

In this article, we saw how to reset the root password on an Ubuntu 24.04 system. Forgetting the password is no longer an issue since you can easily follow this method to update and reset the root password.