Root/admin password recovery on Ubuntu 17.04

Don’t ask me why: maybe you just don’t remember the root password after a nice vacation, or sometimes there is the guy who got out of the company and you need to get into his account to access a specific file, or you just need to get the root access to do something that your current one doesn’t allow to.

To get this business done, it’s quite simple and also work in almost Linux distributions. And don’t, it is not a security failure: you got to have physical access to the computer first. If it is not the case, just forget it. This solution is based on a Ubuntu’s forum answer and this post from I did it this week, and worked like a charm.

Boot up the machine, and after the BIOS screen, hold down the left Shift key. You will then be prompted by a menu that looks something like this:
GRUB menu after pressing the LEFT SHIFT key

I tested the right SHIFT and did not worked at all (as they said). Also there are cases which ESC or SPACE may work for you as well.

Another important thing to notice is that you need to get into the screen with the Ubuntu Kernel version selection screen. But in the GRUB, you step into the screen that looks like the one above. So, you need to select the *Ubuntu option pressing the ENTER key.

Ubuntu kernel version selection screen
Once you reboot to Grub menu, select the first menu item or the menu item you normally use to boot your Ubuntu system and press e to edit:
Ubuntu Kernel startup edition screen
Once in the Grub’s boot menu edit mode use navigation arrows to locate a line starting with linux and edit it to include read-write mode rw and init=/bin/bash.


linux     /boot/vmlinuz-4-X.X-XX-generic root=UUID=43ad24d3-e\
c5b-44ee-a099-a88eb9520989 ro quiet splash $vt_handoff


linux     /boot/vmlinuz-4-X.X-XX-generic root=UUID=43ad24d3-e\
c5b-44ee-a099-a88eb9520989 rw init=/bin/bash
Ubuntu Kernel startup edition screen with rw init=/bin/bash

In a nutshell, just you need to replace ro quiet splash $vt_handoff to rw init=/bin/bash. Use the directional key of the keyboard to navigate in the editor, delete and add. There is no need to save anything, just reboot the computer by pressing F10.

If everything went well, you must see a bash screen with root access. So, you can do anything… including… change any user password!

Bash screen with root access

The next step is the command to change the password.

passwd <username>

And the final step is to reboot the computer. Do not use the reboot or shutdown -r now.

exec /sbin/init

And that’s it. Have fun!