Reset Ubuntu Root Password Through GRUB

User Author

Achilles.H

August 12, 2024

Reset Ubuntu Root Password Through GRUB

Forgetting the root password on your Ubuntu system can be a frustrating experience, but fortunately, it's not the end of the world. Ubuntu provides a built-in method to reset the root password using the GRUB bootloader. This process is relatively simple and doesn’t require any external tools or complicated steps. In this article, we’ll walk you through the process of resetting the root password on Ubuntu by using the GRUB menu and recovery mode.

Step 1: Access GRUB Menu and Recovery Mode

1. Restarting your Ubuntu system. As it begins to boot up, press and hold the Shift key.

This action will bring up the GRUB menu, which is the bootloader used by Ubuntu.

2. In the GRUB menu, you’ll see several boot options. Navigate to the option labeled "Advanced options for Ubuntu" using the arrow keys, and press Enter.

This will open a submenu with additional boot choices.

Advanced options for ubuntu

3. From the submenu, select the entry labeled "Ubuntu, with Linux 6.8.0-38-generic (recovery mode)".

This option will boot Ubuntu into recovery mode, a special mode used for system recovery and troubleshooting.

recovery mode

Step 2: Access the Root Shell

After selecting the recovery mode, your system will boot into a menu called Recovery Menu. This menu provides various options for repairing and recovering your Ubuntu system.

1. Use the arrow keys to navigate to the dpkg option and press Enter. This step is necessary to prepare the system for entering the root shell.

dpkg

2. When prompted, select "Yes" to continue. Then, type d to display details.

continue Yes

3. Finally, type !/bin/bash and press Enter. This command will drop you into a root shell, where you have full access to the system as the root user.

enter root shell
!/bin/bash

Step 3: Reset the Root Password

Now that you have root access, you can reset the root password using the passwd command.

1. Type passwd and press Enter. The system will prompt you to enter a new password for the root user.

passwd

Tip: Make sure your new password is strong (at least 8 characters long, containing a mix of letters, numbers, and symbols). You will need to enter it twice, and for security reasons, the characters won’t appear on the screen.

2. Once you’ve successfully reset the root password, type reboot and press Enter. This command will restart your system, and you can use root user with the new root password.

reboot
reboot

Summary

Resetting your Ubuntu root password through GRUB is a straightforward process that can be completed in just a few steps. This method is also applicable to other Linux distributions like Debian and Linux Mint. It’s especially useful if you haven’t used the system in a while and have forgotten all user passwords. If you remember the password of a user with sudo privileges, you can reset the root password directly from within the system using the sudo passwd root command.

By following these steps, you can regain control of your Ubuntu system and ensure that you always have access to administrative functions.