How to Reset Ubuntu Password in 2 Minutes

How to Reset Ubuntu Password in 2 Minutes

Brief: If you forgot the user password in Ubuntu, don’t worry. You can reset Ubuntu password very easily. This guide shows an easy method to change the root password in Ubuntu. The method should also be applicable to other Linux distributions.

Forgot the Ubuntu login password? It Happens.

If you don’t use Ubuntu for some time, it is only natural to not remember the password. Good news is that you don’t need to reinstall the entire operating system because of it. You can recover Ubuntu password easily.

The method mentioned here work for resetting Ubuntu password in VMware, dual boot or single install. All you need is a little bit of patience and run a couple of commands. You’ll reset the root password within minutes.

Reset Ubuntu password from the recovery mode

If you prefer watching videos over reading text, I have also made a video of this tutorial. Don’t forget to subscribe to our YouTube channel for more Linux tutorial videos.

Step 1: Boot into the recovery mode

Switch the computer on. Go to Grub menu. Generally, it appears automatically, if not then hold down the shift key until the boot menu appears.

If you are using Oracle VirtualBox or VMWare, you have to hold down the shift key when the logo of Oracle or VMWare appears.

In the grub menu, select the “Advanced Options for Ubuntu”:

Advanced boot options in Grub menu of Ubuntu
This is grub screen

In here, you’ll see the option to go to the recovery mode:

Boot into recovery mode

It will bring you a black screen with several lines of output being displayed in a flash. Wait for few seconds here.

Step 2: Drop to root shell prompt

Now you will be present with different options of recovery mode. Here you need to choose “Root Drop into root shell prompt“.  Just press enter key to select this option. Like in the picture below:

Root shell prompt allows you to reset password in Ubuntu

You’ll see that when you select the root shell prompt option, an option to enter commands appear in the bottom. This is your root shell prompt and this is where you’ll use the commands to reset the password.

Step 3: Remount the root with write access

You need to have write access to the root partition. By default, it has only read-only access.

Use the command below to remount it with write access:

mount -rw -o remount /

Step 4: Reset username or password

Here, you will be presented with root access. Use the following command to list all the users available:

ls /home

From the previous command choose the “username” for which you want to reset or (say) hack the password. Now, use the following command to reset the password for the selected “username“:

passwd username

It prompts for a new password. Enter the new password twice:

Enter new UNIX password:
Retype new UNIX password:

Voilà! There you go. You have just successfully reset the password. Now exit the root shell prompt:

exit

When you exit, you’ll be back to the recovery mode menu. Select normal boot option here.

Use recovery mode to boot normal after resetting password in Ubuntu

There will be a warning about graphics mode compatibility. Don’t worry. A complete reboot will fix the issue if there is any.

You should be able to log in with the new password.

Possible Troubleshoot:

While entering the new password you might be prompt with Authentication token manipulation error like this:

passwd username
Enter new UNIX password:
Retype new UNIX password:
passwd: Authentication token manipulation error
passwd: password unchanged

The reason for this error is that file system is mounted with read access only. Change the access and remount the file system in the following manner:

mount -rw -o remount /

Now try to reset the password again. It should work now.

As you can see, it is extremely easy to change Ubuntu password even if you forgot the login. It will hardly take a few minutes.

Alternate method to reset Ubuntu pasword

If for some reasons, you have difficulties in dropping to the root shell and changing the password, you may try these steps.

Step 1

Reboot your computer. Hold shift to bring up the grub screen (if it doesn’t automatically). Press E at the grub prompt to edit the grub screen.

Step 2

Find the line starting with linux, change the ro to rw and append init=/bin/bash at the end of that line

Editing grub to fix frozen boot issue with Ubuntu Linux
Change ro to rw and add init=/bin/bash at the end of this line

Step 3

Press ctrl-x to save your changes and boot.

Now you are booting into Linux kernel with read and write permission and instead of going to graphical user interface, you’ll use the bash shell.

In other words, your system will boot up to a passwordless root shell.

Step 4

Type in the passwd command with your username. If you don’t know the username, check with ls /home command (as mentioned in the method 1).

Set your new password.

Once you have set the new password, exit the terminal. Just type the reboot in the terminal or use the shutdown command.

shutdown -r now

Your password should be changed now.

If resetting Ubuntu password is this easy, is this not a security risk?

That’s a fair question. One of the main advantages of Linux over Windows is the security. But if ‘anyone’ can reset the password, how come Ubuntu or other Linux distributions can be considered secure?

Let me explain a few thing here. The main security risk is if someone could hack your account from a remote location via internet. That’s not happening here.

If anyone has physical access to your computer, the data in your computer is already at risk. Unless the entire disk is encrypted, anyone can ‘steal’ your data using a live USB without even entering your installed operating system.

Ubuntu by default doesn’t have a root password and the root account is locked. The user account you set up while installing Ubuntu is included as an admin with sudo rights. But that doesn’t mean that you are root.

This lack of root password is a feature and the “advanced option for Ubuntu” in the boot menu allows you to preform some specific root related tasks from the “root shell prompt”. This is why you are able to reset Ubuntu password through this method.

If you want to make your system more secure, you can either encrypt the disk (to save your data) or setup a password for root user in Ubuntu.

I hope I made things clear about resetting forgotten password in Ubuntu.

Leave a Reply

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