If you’ve ever lost your password, you’re not the only one. It’s definitely one of the most popular issues with tech support that people have throughout the years. The good thing is that, due to a forgotten password, you do not have to reinstall the whole operating system. In Ubuntu, they have made it extremely easy to restore your password. In VMware, single or dual boot, the methods listed here work to restore the Ubuntu password, and you’ll be able to restore your login credentials within minutes.

Let’s start by demonstrating Ubuntu Password Reset from Recovery Mode.

Booting into Ubuntu recovery mode:

Turn on your computer system and go to the grub menu. Mostly it appears immediately, but if that doesn’t happen, press escape or hold the shift key down until it appears. While working on VM-ware or VirtualBox, when the Oracle or VM-ware logo appears, you have to press the shift key. GRUB menu will be prompted to your screen, here select “Advance Options for Ubuntu“.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/1.jpg" data-lazy- height="589" src="data:image/svg xml,” width=”876″>

Now an option will be displayed, select it to go to the recovery mode:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/2.jpg" data-lazy- height="587" src="data:image/svg xml,” width=”872″>

You will see a black screen with a flash showing multiple lines of data. Here, wait for some time.

Root shell prompt:

You will be provided with numerous recovery mode options here. Select the one named “Root – Drop to Root Shell Prompt” from the given options. Press enter, and you’re all set.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/3.jpg" data-lazy- height="383" src="data:image/svg xml,” width=”711″>

You’ll see that there is an option to enter commands at the bottom when you choose the root shell prompt option. This is the prompt for your shell, and here you will be doing some magic to restore your forgotten password.

Remount root filesystem with write access:

By default, the root partition has given read-only privileges. But here you have to provide root and write access too. To remount it with write permission, use the following command:

Reset username or password:

List the available users using the following command once you will be provided with the root access :

Or you can see the available users by displaying the contents of /etc/passwd file using the following command:

From the usernames accessible, select the one for which you’d prefer to reset the password. Now, reset the password for the chosen username by typing the following command:

It will ask you for a new password. Type the new password once and then again to confirm it:

You have restored your password successfully. Enter the Exit command for exiting the root shell.

On entering exit command, we will prompt back to the Recover Boot menu. Now, choose the standard boot option on the screen. There will be an alert about compatibility with the graphics mode. You don’t have to worry about it. A reboot will solve all these compatibility issues. Now we just have to log in with the password we just have set.

Possible Error:

    You may be encountered with Authentication token manipulation error when entering the new password:

    <img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/4.jpg" data-lazy- height="195" src="data:image/svg xml,” width=”964″>

    The cause for this error is that it is still mounted with Read-Only access. To overcome this, just type the command for remounting the file system and modify the access.

    <img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/5.jpg" data-lazy- height="54" src="data:image/svg xml,” width=”894″>

    Change the password once again. It will work now without displaying any errors.

Alternate method for resetting the password:

If you have trouble changing the password via root shell for some reason, you should follow these steps:

Step 1

Get the computer rebooted. To bring up the grub screen, hold the shift key for some time. To edit the Grub panel, click E.

Step 2

From the given set of lines, find any line starting with “Linux” using the up and down arrow keys and change access from read-only to read-write by just replacing ro recovery nomodeset to rw init=/bin/bash.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/6.jpg" data-lazy- height="489" src="data:image/svg xml,” width=”750″>

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/7.jpg" data-lazy- height="494" src="data:image/svg xml,” width=”750″>

Step 3

To save the changes and to boot, press ctrl-x. You are now booting with both read and write access into a Linux kernel, here you can use the bash shell instead of GUI. In other words, a passwordless root shell will boot into your system.

Step 4

Type your username into the passwd command. If the username is unknown, search with the ‘ls /home’ or ‘cat /etc/passwd | grep -i bash’ command. Now reset the password and then exit the terminal. After it’s done, reboot using the following commands and you are good to go.

Conclusion:

Ubuntu’s root account will be locked as it does not have a root password by default. A user account you set up before installing Ubuntu is included as an administrator with sudo privileges. Yet, in any capacity, it doesn’t imply that you are root. This absence of a root password is an intended feature of Ubuntu. “The boot menu for “Ubuntu Advanced Options” allows you to perform certain root-related functions from the “root shell prompt.” This is why you can reset the Ubuntu password from this method.

Question is If it’s this quick and easy to restore Ubuntu passwords, isn’t this a security risk? The major security threat is if someone breaks into your account from a different location through the internet. It’s not occurring here. In case that some malicious entity has physical access to your computer system, its security is already at extreme risk. Well, if you want not to have this feature, you can disable it by encrypting your Hard Drive via LUKS encryption while installing Ubuntu.

About the author

<img alt="Usama Azad" data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/usama-1-150×150.jpg" height="112" src="data:image/svg xml,” width=”112″>

Usama Azad

A security enthusiast who loves Terminal and Open Source. My area of expertise is Python, Linux (Debian), Bash, Penetration testing, and Firewalls. I’m born and raised in Wazirabad, Pakistan and currently doing Undergraduation from National University of Science and Technology (NUST). On Twitter i go by @UsamaAzad14