Reset root password in Linux VM
Steps for changing root password:
- Navigate to the VM details page.
- Click STOP to shutdown the VM and wait for the VM to be stopped.
- Optional Create a VM snapshot prior to making any changes.
- Click START to start the VM.
- Click CONSOLE to navigate to the console while the VM is booting.
- Follow the OS specific instructions to interrupt the boot process and reset the passwords via the VM console.
- Verify the new password by restarting the VM and logging in with the new password.
- Optional Delete the snapshot created in step 3.
OS specific instructions
Reset root password for CentOS 8:
- Press Esc to interrupt the boot process, then press the E key.
- Add rd.break at the end of the line that starts with
linux($root)/
. - 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:
- Press Shift + Esc several times until the boot process is interrupted, then press the E key.
- Replace everything after
ro
with rw init=/bin/bash in the line that starts withlinux /vmlinuz-
. - Press Ctrl-x to the shell prompt and execute the following commands:
passwd
exec /sbin/init