Skip to content

Reset root password in Linux VM

Steps for changing root password:

  1. Navigate to the VM details page.
  2. Click STOP to shutdown the VM and wait for the VM to be stopped.
  3. Optional Create a VM snapshot prior to making any changes.
  4. Click START to start the VM.
  5. Click CONSOLE to navigate to the console while the VM is booting.
  6. Follow the OS specific instructions to interrupt the boot process and reset the passwords via the VM console.
  7. Verify the new password by restarting the VM and logging in with the new password.
  8. Optional Delete the snapshot created in step 3.

OS specific instructions

Reset root password for CentOS 8:

  1. Press Esc to interrupt the boot process, then press the E key.
  2. Add rd.break at the end of the line that starts with linux($root)/. grubshell
  3. Press Ctrl-x to the shell prompt and execute the following commands:
    mount -o remount rw /sysroot
    chroot /sysroot
    touch /.autorelabel
    exit
    reboot
    

Reset root password for Ubuntu 20:

  1. Press Shift + Esc several times until the boot process is interrupted, then press the E key.
  2. Replace everything after ro with rw init=/bin/bash in the line that starts with linux /vmlinuz-. grubshell
  3. Press Ctrl-x to the shell prompt and execute the following commands:
passwd
exec /sbin/init