If you have forgotten your Ubuntu user password and have some valuable data on the system then don’t think to format it because you can recover it. In the Ubuntu, it is super easy to recover the user password if you know the root password. And if you also forgot the root password then see our tutorial on “Resetting the root password on Ubuntu with knowing it“.
But right now, in this tutorial, we assume that you know your Ubuntu’s root password and will tell you how to reset that using Grub. The tutorial will work for almost all current active versions of Ubuntu such as Ubuntu 12.04, Ubuntu 41.4, Ubuntu 16.04, Ubuntu 16.10 and Ubuntu 17.04.
Note: While creating the Ubuntu password reset guide we were using the Ubuntu 17.04.
Reset Your Ubuntu Password Using Grub
If you forgot the Ubuntu password of ‘XYZ ‘user then restart your PC and follow the given steps.
Step 1: First step is to restart your Ubuntu Linux box and when bios appear press and hold the shift key from the keyboard to get the Ubuntu Grub menu. When the Grub has appeared on your system, it will look like same as the given screenshot.
Step 2: Once the grub appears, select the “Advanced option for Ubuntu“. After selecting the advanced option you will see couple of other options, now select the “Ubuntu, with Linux recovery mode”
Step 3: Now you would see something like below screenshot. Using arrow key select the option “Drop to root shell prompt”.
Step 4: Now it will ask for the root password, type your root password and hit the enter button.
Step 5: After keying the root password and hitting the enter button you will see the something like this:
Note: h2s is our username and in your case, it reflects yours.
Step 5: So, you successfully got the root access but still the file system is read-only and you need to remount it with write permission. To do that use the following command:
mount -o rw,remount /
Step 6: I assume in your case you have also successfully mount the filesystem and now its time to change your Ubuntu user password. Type the command
Note: Replace the h2s with your username whose password you wan tot reset.
overview of executed commands:
The above tutorial needs the root password of Ubuntu and if you don’t know it and want to know how to reset the Ubuntu root password with knowing it. You can see: How To Change Ubuntu Root Administrative password, if Forgotten