How to recover my forgotten user password in Ubuntu from the terminal?

Who I am
Philippe Gloaguen
@philippegloaguen
EXTERNAL REFERENCES:

vgr.com gamedesigning.org Reddit.com

Author and references

It happens to everyone that at some point they forget the password to log in to your computer. As much as you try different combinations of numbers and letters, you can't find the right one. Don't worry, here's how to recover forgotten Ubuntu user password from terminal.

This type of case is more common than it seems and happens to everyone at some point in their lives. As much as you want to remember it, the password just doesn't appear in your head. This can be a big problem. However, there is a solution and it's easier than it sounds, since free software will help you through every step (Linux is so good that you can even recover your Windows password from it, and that they are theoretical rivals).



      Recover the user password with the administrator key

      One of the fastest options to recover forgotten user password in Ubuntu is through the administrator password.

      If you share your computer with someone else and they have administrator rights, you can recover your password quickly. You just have to write the following in the terminal:

      You should start by typing "~$ sudo passwd youruser" and press the "Enter" key. Then enter "Enter new UNIX password" . After running it you need to add "Ridiculous new password UNIX" and run again. Finally, write in the terminal “passwd: password updated successfully” . And that's it, now you can reset your user password.

      This is the fastest way to recover your password. However, what if you don't have administrator access? This is where things get a little complicated.



      But more complicated doesn't mean impossible. So here you have another option to recover forgotten user password in Ubuntu from terminal.

      Recover forgotten user password in Ubuntu from terminal

      The first thing to do is to restart your computer and press the " Esc ” . As soon as the GRUB menu appears, you should go to the section "Recovey Mode" but without pressing the " Submit ".

      When you are on the option "Recovery mode" you need to press the " E " on your keyboard. This will allow you to change the boot options. When you are in the boot options window, you need to locate the following address: "Linux /boot/vmlinuz-3.2.0-18-generic root=UUID=b8b64ed1-ae94-43c6-92d2-a19dfd9a727e ro recovery nomodeset:".

      You have to select it and replace "Recovey nomodeset" with the following: "rw init=/bin/bash:". This will change the way your computer starts up. This will boot into recovery mode and the command prompt will appear.

      Then you need to press the F10 key to load the changes and restart the system. If you did everything correctly, a black screen should appear where you have to write the following command: “/usr/sbin/usermod -p 'our password without quotes' "our username without quotes".

      recover username

      If you forgot your username as well, you can find it out with the command “ lastb.” What it will do is check who was the last user to try to log into the system.


      Another way to do this is to search for a list of all system users with the following command: “cat /etc/passwd | taglia -d":" -f1".



      It may be necessary to change the password of the root user or the one with the most privileges in the system. For this you will have to run the command: “usr/sbin/usermod -p 'our password without quotes' root”.

      To complete the process of recovering forgotten user password in Ubuntu from the terminal, you just have to restart your PC and wait for it to turn on again. The next thing is to enter your username and password normally to be able to access your session.


      It may seem like a complicated process, but it really isn't. You just have to follow each step of the tutorial correctly and add the commands as indicated. This way you can log back into your session and recover all your files.

      Remember that in addition to recovering your username, you can also change the forgotten root password in case you lost that too. And to complete the use of the terminal, it is recommended to look for more commands such as the one that allows you to rename files in Linux or the one that allows you to hide files and folders in Ubuntu .

      add a comment of How to recover my forgotten user password in Ubuntu from the terminal?
      Comment sent successfully! We will review it in the next few hours.