18.6 C
New York

Resetting Forgotten Root Password on Ubuntu Server

Published:

On Linux-based systems like Ubuntu, the root account has the most privileges and control over the system. Users need the root password to make administrator-level changes. If you forget your root password on Ubuntu, you can reset it by modifying the GRUB boot loader and booting into recovery mode. This article explains how.

Resetting the Root Password

To change the root password, open the terminal with Ctrl+Alt+T or from Applications > Terminal. Then type:

sudo passwd root 

Enter and re-enter your new password when prompted. This will reset the root password.

If you’ve forgotten the root password completely, follow these steps:

Step 1: Reboot and Enter Recovery Mode

When rebooting, press Shift during splash screen to enter the GRUB menu. Select Ubuntu and press “e” to edit boot options.

Step 2: Edit the Boot Configuration

Use arrow keys to navigate to the “linux” line ending with “ro quiet splash”. Replace this with “rw init=/bin/bash”.

Step 3: Reboot Into Recovery Shell

Press Ctrl+X or F10 to reboot with the edited config. This enters a root shell. Verify the root file system mounted properly:

mount | grep -w /

Step 4: Reset Root Password

Use the passwd command to reset the root password:

passwd

Enter and re-enter a new root password.

Conclusion

By editing GRUB and entering recovery mode, you can reset a lost root password on Ubuntu 20.04. Reboot to apply the new password. This provides admin access if you forget your credentials.

Related articles

Recent articles