How to Change Root password in Ubuntu Virtual Machine

In order to access the grub menu on a virtual machine, you need to hold the shift key down for a while. You must let your virtual machine to capture your mouse before holding the shift key. Follow the steps to change your password:

1. Let your virtual Machine to capture your mouse.
2. Hold the shift key down to get the grub menu.
3. Select the recovery mode option.
4. Select drop to root shell prompt.

After immediately selecting ‘Drop into root shell prompt’ I found the filesystem was mounted read only, which prevents resetting the password and got some error like

passwd: Authentication token manipulation error
  passwd: password unchanged

To fix this I had to run following command

  mount -rw -o remount /

Now you can change the root password using the command  :

passwd root

This would ask for new password and on entering it it would succefully chage the same too.

reference :