How to reset the password in Ubuntu

I think it happened to you at least once to forget the password you use to log in to your computer and you asked yourself how to reset it. If you use the Ubuntu operating system and don’t know how to reset your password, you can find out today by reading this article.

How to reset your Ubuntu password

I forgot the password myself more than once. And I didn’t know what to do next to recover it. I kept trying with the old passwords that I had used before. Unfortunately, this process is difficult and sometimes unsuccessful.

These are the steps you need to follow in order to reset your password. I am using a VM with the Ubuntu version 22.04.

Ubuntu 22.04

Reboot or start the PC/VM

The first thing you need to do is, of course, turn on the computer. If you have reached the page where you are asked to enter the authentication data and you do not know it, you can try to guess the password.

Guess the password

If the guessing process does not bring the expected results, you need to reboot the system.

Restart the system

Select the Advanced options from the displayed list

Once you have restarted the computer and it begins to boot, hold down the Shift key on the left side of the keyboard (if you use BIOS). If you use UEFI, you will need to press the Esc key two times. You will soon see a menu that looks like the one below. From the menu, select option number 2.

Advanced options for Ubuntu

Select the Ubuntu (recovery mode)

After selecting the option “Advanced options for Ubuntu”, you will be presented with a screen similar to the below one. You need to select an option which has the recovery mode in parentheses.

Select a kernel version with the recovery option in parentheses

Select root from the Recovery menu

As soon as the recovery menu appears, you can select one of the multiple options using the up-down arrows key. To reset the password, you need to select the root option from the recovery menu.

Select drop to root shell prompt

Mount the / directory with read and write permissions

Once you have access to the terminal, use the command below to mount the / directory with read and write permissions. We do this so that the changes we make for a certain username are saved in the operating system.

mount -rw -o remount /
Mount the / directory with read and write permissions

Reset the password

After mounting the root directory in read and write mode, you can finally reset the password that was giving you trouble. For this, we will use the command below.

passwd username
Reset the password

Reboot the operating system

After making the necessary changes (resetting the password), write down the new entered password on a piece of paper and continue restarting the computer. For this, use the command below.

shutdown -r now
Reboot the operating system

Test the new password

These are the steps you need to follow to reset your password on Ubuntu/Linux. Now, let’s test the new password. As you can see, I was able to log in successfully.

Here you can find a short video with the steps to follow.

I hope you find this article useful and you won’t face any difficulties the next time you forget your password. 🙂

PS: If you liked the article, please leave your comment below.

Processing…
Success! You're on the list.

Leave a Reply