In systems based on the Linux platform, the root account is first in the user role hierarchy. The root user has the most power over the Linux system. In these systems, users need the root user’s permission to make changes. The root user, by virtue of his exclusive rights, is authorized to change and override the permissions of other users. In the case of an Ubuntu system, the default root user account is initially disabled, but users can still make relevant changes if they know the system’s root password. The real problem occurs when users forget the root user password in their system. In this article, I will show you how to reset the root password on an Ubuntu 20.04 system by modifying the Grub boot loader configuration and booting Ubuntu into a 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.
When you will press the <enter> key from the keyboard, the password will then be updated successfully.
Resetting the root password
When users have forgotten their root password, then they need to enter the password of the user.
Step 1: Booting to Recovery
To begin with this method, users need to restart their system. As soon as the splash screen appears, press the <shift> key from your keyboard. The GNU GRUB screen will appear as displayed below:
This is the boot menu for Ubuntu that has different kernel versions that are displayed and has different options. Select the option Ubuntu by pressing the <enter> key. When you selected Ubuntu, you need to press the “e” key to open up the grub parameters that are to be edited.
Step 2: Changing the configurations
After that use arrow keys again and then scroll down further to the bottom line that begins with “linux /boot/vmlinuz” keyword.
From the above-highlighted line, you need to replace “ro quiet splash $vt_handoff” word with “rw init=/bin/bash”.
Step 3: Rebooting the system
The next step is to reboot your system. This will be done by using the Ctrl + X or by using the F10 key. It will help you to reboot the system along with the updates you made in your system. The system will restart and then you will be landed to your root shell of the system. The shell will appear only one-time and in future, it will appear normally.
To see that if your root file system has been mounted correctly, you need to append the following command in the shell.
$ mount | grep -w /
Step 4: Changing the root password
To change the root password, type the following password command:
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.
Once the password is updated, a success message will appear on the screen.
The password is now changed/rest successfully. To confirm the updates, you can restart your system.
In this article, we saw how to reset the root password on an Ubuntu 20.04 system. Forgetting the password is not an issue anymore since you can easily follow this method to update and reset the root password.