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

It happens to everyone that at some point they forget the password to log in to their computer. No matter how hard you try various combinations of numbers and letters, you can’t find the right one. Don’t worry, here is how to recover your forgotten user password in Ubuntu from terminal.

This type of case is more common than it seems, and it happens to all of them at some point in their life. As much as you want to remember, the password simply does not appear in your head. This can be a big problem. However, it has a solution and is simpler than it seems, since free software will help you at every step (Linux is so good that you can even recover the Windows password from it, and they are theoretical rivals).

Recover user password with administrator password

One of the quickest options to recover your 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 quickly recover your password. You just have to write the following in the terminal:

You must start by typing “~ $ sudo passwd tuusuario” and press the “Enter” key. Then you enter “Enter new UNIX password”. After executing it, you must append “Retype new UNIX password” and again, execute. To finish you write in the terminal “passwd: password updated successfully”. And voila, you can reset your user password.

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

linux mascot with ubuntu logo


But more complicated does not mean impossible. So here you have another option to recover your forgotten user password in Ubuntu from terminal.

Recover your forgotten user password in Ubuntu from terminal

The first thing you should do is restart your computer and press the “Esc.” Key . As soon as the GRUB menu is displayed, you must go to the “Recovey Mode” section but without pressing the “Enter ” key .

When you are on the option “Recovery Mode” you must press the “E ” key on your keyboard. This will allow you to edit the boot options. When you are in the boot options window you should locate the following address: “Linux /boot/vmlinuz-3.2.0-18-generic root = UUID = b8b64ed1-ae94-43c6-92 \ d2-a19dfd9a727e ro recovery nomodeset:”.

You must 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 line will appear.

Then you must press the F10 key in order to load the changes and restart the system. If you have done everything correctly, a black screen should appear where you must type the following command: “/ usr / sbin / usermod -p ‘ourpassword without quotes'” ourusername without quotes “.

Retrieve username

If you have also forgotten your username, you can find out with the “lastb ” command . What this will do is check who was the last user to try to enter the system.

Another way to do it is looking for a list of all the users on the system thanks to the following command: “cat / etc / passwd | cut -d “:” -f1 ”.

official ubuntu user

It may be necessary to change the password of the root user or the one who has more privileges on the system. For this you must execute the command: “usr / sbin / usermod -p ‘our password without quotes’ root”.

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

It may seem like a somewhat complicated process, but it really is not. You just have to correctly follow each step of the tutorial and append the commands as indicated. In this way you will be able to access your session again and recover all your files.

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

Leave a Reply

Your email address will not be published.

Back to top button