We all use a password to secure our system, application, or any data from unauthorized access. But, what will happen if we forget the password by our self? Almost, every device, service, application, and the operating system has the recovery option to reset the password. Here, we will discuss the process how to reset root password in Ubuntu system.
- Also read: Reset Cisco Router Password
In order to reset forgotten root password in Ubuntu, you need restart your Ubuntu system in the password recovery mode, using the advanced GRUB option. Since we are going to perform this activity on Ubuntu 16.04, but similar steps can be used to reset root password for the earlier version of Ubuntu. However, you may need to adjust steps to get the recovery mode on the earlier version of ubuntu such as ubuntu 14.04. If you are working on the latest version of Ubuntu that is Ubuntu 17.04, you can use same steps to reset root password in Ubuntu 17.04.
- Also read: Install MongoDB in Ubuntu 16.04
The following steps need to be performed to reset or recover root or administrator password on Ubuntu:
Starting Ubuntu with Advanced Boot Options
In order to boot Ubuntu with advanced boot options, reboot your system and keep pressing the SHIFT button until the GRUB menu appears. The following figure shows the Ubuntu Grub menu.
Modifying GRUB Menu
On the GRUB boot menu option, you need to go to in the recovery mode. For this, select the Advanced options for Ubuntu in the above-mentioned figure. The advanced boot options will be displayed. Here, you need to select the recovery mode as shown in the following figure.
Selecting Recovery Option
Once you press Enter for the Recovery mode, the system will display various recovery menu options. Here, you need to select the root option and then select Ok as shown in the following figure.
Press Enter for maintenance prompt will be displayed, press Enter to go to the maintenance mode. The root prompt will be displayed.
Now, you need to mount the root filesystem with the read and write permission using the following command.
mount –o rw,remount /
Resetting Password in the Recovery Mode
After mounting the filesystem, you can reset the administrator or root password in Ubuntu system. For this, you need to execute the following commands.
You will be asked to provide the new password for root or administrator. Type the desired password and confirm it. Once the password has reset, use the sudo reboot command to reboot the system.
Refer the following figure to mount the filesystem, reset the root password, and reboot the system.
Login with New Password
Now, try to login with the new password you have given in the previous step. You should be able to login with new password. Hope, it helped you to reset your forgotten root password in Ubuntu 16.04 and Ubuntu 17.04, if you get stuck anywhere or have any doubts/suggestions, we would love to hear you.
- Also read: How To Install LAMP on Ubuntu EC2 Instance