Ubuntu – Reset root password of a VM

passwordsrootUbuntu

I removed (distrattament) my "sudo" user from sudo group user, I can't use root because I don't know a password for root.

I have an Ubuntu virtual machine and when I open Recovery Menu is limited read-only menu.
If I select "root Drop to root shell prompt"
the message is "Give root password for maintenance" … but I don't know the root password.

How can I reset root password?

Best Answer

To recover the root password, you will need to boot into single user mode. In many distrobutions there is a drop down option to let you select at the boot loader. If you are using GRUB, you can select the version of the OS kernel you would like to boot, hit the "edit" key (e I believe), and then append the word "single" to the end of the kernel parameters string. You can find Ubuntu specific instructions here.

Once you have booted into single user mode, you should see a prompt like this:

sh#

To reset the root password, type:

passwd root

At this point you will be prompted to enter a new password and to confirm the password. You can also modify the /etc/sudoers file to add your user back to the sudoers group.

Related Question