CodeSteps

Python, C, C++, C#, PowerShell, Android, Visual C++, Java ...

Ubuntu – How to reset administrator password?

After few weeks of gap, I tried to login into my Ubuntu System. Unfortunately, I forget the password and I tried with different passwords, usually I set to my user accounts; and none of them were matched to login into my System. Finally, I reset my password, using Boot options. And I would like to share the information, how I did it, through this Article.

Step 1. During your Ubuntu system start up, press and hold Shift key. This will open GNU GRUB (GRand Unified Bootloader) boot loader package.

By using Up Arrow or Down Arrow keys, you can move between the displayed options. Select the “Advanced options for Ubuntu” OS and press Enter key to continue with the booting.

Step 2. You will see another screen where GRUB displays list of OSs and select the “recovery mode” OS by using Up or Down Arrow keys; and press Enter key.

Step 3. You will see the recovery menu with multiple options are listed. Select root option. Use Up or Down arrow keys to navigate in the options.

Recovery Menu (filesystem state: read-only)

resumeResume normal boot
cleanTry to make free space
dpkgRepair broken packages
fsckCheck all file systems
grubUpdate grub bootloader
networkEnable networking
rootDrop to root shell prompt!
system-summarySystem summary

<Ok>

Then you will see the below message displayed on the console window;

Press Enter for maintenance
(or press Control-D to continue):

Press Enter key to continue to recover the password.

Observer that, the file system is in read-only mode. That means, you are not allowed to modify anything in the file system.

Step 4. Type the command “passwd <<user-name>>” at the shell prompt. This command is used to change User’s password.

root@ubuntu-UirtualBox:~# passwd sahida
Enter new UNIX password:
Retype new UNIX password:
passwd: Authentication token manipulation error
passwd: password unchanged

 

Notice that, the above command was failed to change the User’s password. Why? As I mentioned above, when the System started in maintenance mode, the files system is in read-only mode. When we attempt to change the password, the information will be saved in /etc/passwd file. As it is not allowed to modify any file in read-only mode; the System throws an Error.

Step 5. To fix above error, we need to set the permissions to allow to modify the file system. During normal boot, it is not required; but, during maintenance mode, we need to set this. Type the below mount command to set this permission;

root@ubuntu-UirtualBox:~# mount -o remount,rw /

This remounts the files system for read and write mode.

Step 6. Now try again, to change the User’s password. It will prompt for new password.

root@ubuntu-UirtualBox:~# passwd sahida
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

 

Now it is successfully changed User’s password.

Step 7. Type exit command, at shell prompt to exit from the maintenance mode and to start to continue the boot sequence. You will see the recovery menu (mentioned in Step 3) as part of boot sequence; select resume option from it to resume normal boot. 

You will see the below prompt before it continue the normal boot. Once you clicked on Ok; this takes you to login screen to allow you to enter login credentials;

You are now going to exit the recovery mode and continue the boot
sequence. Please note that some graphic drivers require a full
graphical boot and so will fail when resuming from recovery.
If that's the case, simply reboot from the login screen and then
perform a standard boot.

<0k>

Step 8. Enter the new password to login into the System.

This is the way we can reset the administrator password in Ubuntu.

🙂 Sahida

Ubuntu – How to reset administrator password?

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top