It happens to everyone that at some point they forget the password to log in to your computer. No matter how hard you try various combinations of numbers and letters, you can't find the right one. Don't worry, here's how to recover the forgotten user password in Ubuntu from the 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 just doesn't appear in your head. This can be a big deal. However, it has one solution and it's simpler than it sounds, as the free software will help you every step of the way (Linux is so good that you can even recover your Windows password from it, and they're theoretical rivals).
Retrieve the user password with the administrator password
One of the quickest options to recover the forgotten user password in Ubuntu is via the admin 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 need to start typing "~ $ Sudo passwd tuusuario" and press the «Enter» key. Then enter "Enter new UNIX password". After running it, you need to add "Retype the new UNIX password" and again run. Finally type 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 administrator access? That's where things get a little complicated.
But more complicated doesn't mean impossible. So here you have another option to recover the forgotten user password in Ubuntu from the terminal.
Recover your forgotten user password in Ubuntu from the terminal
The first thing to do is to restart the computer and press the » Esc ". As soon as the GRUB menu appears, you need to jump to the section "Recovery mode" but without pressing the button " Submit «.
When you are on the option "Recovery mode" you have to press the " E »On the keyboard. This will allow you to change the startup 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 need 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 line will appear.
Then you need to press the F10 key to load the changes and reboot the system. If you've done everything correctly, a black screen should appear where you need to type the following command: “/ Usr / sbin / usermod -p 'our password without quotes'» our username without quotes «.
Retrieve username
If you have also forgotten your username, you can find out with the command " lastb ". What it will do is check who was the last user to attempt to log into the system.
Another way to do this is to search for a list of all users on the system thanks to the following command: “cat / etc / passwd | taglia -d «:» -f1 ”.
You may need to change the password of the root user or the one who has more privileges on the system. For this you need to run the command: "Usr / sbin / usermod -p 'our password without quotes' root".
To complete the process of recovering the 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 the username and password normally to log into your session.
It may seem like a bit of 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 will log in again to the your session and recover all your files.
Remember that in addition to recovering your username, you can also change your forgotten root password in case you have lost that as well. And to complete the use of the terminal, it is recommended to look for more commands like the one that allows you to rename files in Linux or the one that allows you to hide files and folders in Ubuntu.