How do I change the Virtual Machine root password in single-user mode?

Cause

If the administrator has forgotten the Virtual Machine root password and QGA is not installed (preventing an online password change), you must enter single-user mode to change the root password manually.

Solution

  1. Open the Virtual Machine console. On the GRUB boot menu, position the cursor on the first entry and press e to enter edit mode.

  2. Position the cursor after .UTF-8 and append init=/bin/sh on the same line after .UTF-8. Ensure correct spacing.

  3. Press Ctrl+x to boot.

  4. After booting successfully, run mount -o remount,rw / to mount the root directory.

  5. Run passwd to reset the password.

  6. Run exec /sbin/init or exec /sbin/reboot to exit single-user mode.

  7. Restart the Virtual Machine and log in to the operating system with the new password.

On this page