Home Linux How to Reset Forgotten Root Password in Ubuntu

How to Reset Forgotten Root Password in Ubuntu

0
How to Reset Forgotten Root Password in Ubuntu


It’s a common scenario – you’re working on your Ubuntu system and suddenly realize you’ve forgotten the root password, which can be a frustrating experience, as the root account is essential for performing critical administrative tasks.

However, don’t worry, in this article, you will learn how to reset the forgotten root password on Ubuntu 24.04, Ubuntu 22.04, and Ubuntu 20.04 LTS.

Step 1: Access the GRUB Menu

Firstly, you need to either power on or reboot your Ubuntu system, and when the system is booting up, press the Shift or ESC key on your keyboard to bring up the GRUB menu, which provides various options for booting your system.

If you are running your system on VirtualBox, press the ‘SHIFT’ key on the keyboard to bring up the boot menu.

Ubuntu Grub Menu
Ubuntu Grub Menu

Step 2: Edit the GRUB Menu Options

Once you’re in the GRUB menu, use the arrow keys to navigate to the Ubuntu entry and press the 'e' key to edit the grub parameters.

Grub Boot Parameters
Grub Boot Parameters

Scroll down until you get to the line that begins with 'linux the entire line is highlighted below.

Find Grub Boot Parameter
Find the Grub Boot Parameter

Narrow down to a section that reads "ro quiet splash $vt_handoff".

Locate Grub Boot Parameter
Locate the Grub Boot Parameter

Replace "ro quiet splash $vt_handoff" with rw init=/bin/bash as shown. The aim is to set the root file system with read and write commands denoted by the rw prefix.

Enable Root Filesystem
Enable Root Filesystem

Thereafter, press ctrl + x or F10 to reboot your system.

Step 3: Remount the Root Filesystem

Your system will boot into a root shell screen as shown below. You can confirm that the root filesystem has read and write access rights by running the command.

# mount | grep -w /

The output in the screenshot below confirms read and write access rights denoted by rw.

Confirm Root Filesytem Permissions
Confirm Root Filesystem Permissions

Step 4: Reset the Root Password

With the root filesystem mounted in read-write mode, you can now reset the root password using the passwd command:

# passwd 

Provide a new password and confirm it. Thereafter, you will get a ‘password updated successfully’ notification.

Reset Root Password in Ubuntu
Reset Root Password in Ubuntu

After resetting the root password, it’s a good idea to remount the root filesystem in read-only mode to enhance system security.

mount -o remount,ro /

Finally, reboot your Ubuntu system to apply the changes and allow you to log in with the new root password

exec /sbin/init
OR
reboot

After the reboot, you should be able to log in as the root user using the new password you set.

Conclusion

Resetting the forgotten root password in Ubuntu is a straightforward process that can be completed in a few simple steps.

By accessing the GRUB menu, editing the boot options, and using the root shell to reset the password, you can regain full administrative access to your system.

Remember to choose a strong, secure password and remount the root filesystem in read-only mode for enhanced security. With this guide, you should be able to quickly and easily reset the root password on your Ubuntu system.



Source link

netbalaban news