Ubuntu – How to reset a lost administrative password

password-recovery

I'm working on a Ubuntu system, and my client has completely forgotten his administrative password. He doesn't even remember entering one; however it is there.

I've tried the suggestions on the website, and I have been unsuccessful in deleting the password so that I can download applets required for running some files. Is there a solution?

Best Answer

By default the first user's account is an administrative account, so if the UI is prompting you for a password it's probably that person's user password. If the user doesn't remember their password you need to reset it. To do this you need to boot into recovery mode (see also offical docs: RecoveryMode).

Boot up the machine, and after the BIOS screen, hold down the left Shift key (note that for UEFI BIOS you might need press ESC instead). You will then be prompted by a menu that looks something like this:

enter image description here

I've noticed on some systems that timing when to hit the left Shift key can be tricky, sometimes I miss it and need to try it again.

Hit the down arrow until you select the 2nd entry from the top (the one with the recovery mode in the description) and then hit Enter.

Now you should see this menu:

enter image description here

Using the arrow keys scroll down to root and then hit Enter.

You should now see a root prompt, something like this:

root@ubuntu:~#

At this stage you should have a read-only filesystem. You have to remount it with write permissions:

mount -o remount,rw /

Now we can set the user's password with the passwd command. (In this example I will use jorge as the example, you need to substitute whatever the user's username is):

root@ubuntu:~# passwd jorge
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
root@ubuntu:~#

Type in what you want the new password to be at the prompt. After it's successful reboot the machine and the user will be able to log in with their new password.


There is concern about this being a security vulnerability. It is not. You need to have physical access to the machine to do this. If someone has physical access to your PC, they could do far worse than change a password. When it comes to physical access, the battle for security is lost. Be wary of who you let on your PC.

Even setting a root password will not be successful, as one can simply boot with init being /bin/sh and have full root access. Again, given physical access, anyone with computer knowledge can do ANYTHING to your computer.

Related Question