Search code examples
ubuntupasswordsrootreset

Forget ubuntu 18.04 root password


I forgot my ubuntu 18.04 in virtual machine (VM) root password. To reset this password, I press "esc+enter" while restarting the machine, then select Advanced options to get the following menu:

Ubuntu, with Linux 4.15.0-34-generic
Ubuntu, with Linuc 4.15.0-34-generic (recovery mode)
Ubuntu, with Linux 4.15.0-34-generic
Ubuntu, with Linuc 4.15.0-34-generic (recovery mode)
Ubuntu, with Linux 4.15.0-34-generic
Ubuntu, with Linuc 4.15.0-34-generic (recovery mode)

The same group of items appear three times in my VM. I picked up the recovery mode --> "root Drop to root shell prompt". Then, I got:

Give root password for maintenance
(or press Control-D) to continue):

I tried both Ctrl+d and Crtl+shift+d (Ctrl+D), but both of them brought me back to the menu that contains:

root     Drop to root shell prompt

Then, this process circles. Does anybody know where the problem is?


Solution

  • You will need to edit your grub boot loader and add the line:

    rw init=/bin/bash
    

    Further information can be found here:

    https://www.google.com/url?sa=t&source=web&rct=j&url=https://linuxconfig.org/how-to-reset-lost-root-password-on-ubuntu-18-04-bionic-beaver-linux&ved=2ahUKEwirhNmrkP3tAhU-XRUIHRYyC6YQFjAAegQIARAB&usg=AOvVaw0PkoGfLH_PtztNdQ3TSRk7