For situations where the root password on a Linux device has been lost.
Boot into Single User Mode
- Restart the server
- You will see a GRUB boot prompt telling you to press any key - you have only a few seconds to press a key to stop the automated booting process. (If you miss this prompt you will need to restart the VM again)
- At the GRUB prompt, type A to append to the boot command.
- Add the text single and press ENTER.
- The system will boot and you will see the root prompt. Type passwd to change the root-password and then reboot again.
- Restart the server
- As soon as the boot process starts, press ESC to bring up the GRUB boot prompt. You may need to turn the system off from the control panel and then back on to reach the GRUB boot prompt.
- You will see a GRUB boot prompt - press E to edit the first boot option. (If you do not see the GRUB prompt, you may need to press any key to bring it up before the machine boots)
- Find the kernel line (it starts with "linux16"), change ro to rw init=/sysroot/bin/sh.
- Press CTRL+X or F10 to boot single user mode.
- Access the system with the command: chroot /sysroot.
- Run passwd to change the root password.
- Reboot the system: reboot -f.
- Restart the server
- As soon as the boot process starts, press ESC to bring up the GRUB boot prompt. You may need to turn the system off from the control panel and then back on to reach the GRUB boot prompt.
- You will see a GRUB boot prompt - press E to edit the first boot option. (If you do not see the GRUB prompt, you may need to press any key to bring it up before the machine boots)
- Find the kernel line (it starts with "linux"), change ro to rw init=/sysroot/bin/sh.
- Press CTRL+X or F10 to boot single user mode.
- Access the system with the command: chroot /sysroot.
- Run passwd to change the root password.
- Run touch /.autorelabel to force file system relabeling.
- Run exit.
- Run logout.
- Reboot the system: reboot.
- Restart the server
- As soon as the boot process starts, press ESC to bring up the GRUB boot prompt. You may need to turn the system off from the control panel and then back on to reach the GRUB boot prompt.
- You will see a GRUB boot prompt - press E to edit the first boot option. (If you do not see the GRUB prompt, you may need to press any key to bring it up before the machine boots)
- Find the kernel line (it starts with linux /boot/) and add init=/bin/bash at the end of the line.
- Press CTRL+X or F10 to boot.
- The system will boot and you will see the root prompt. Type mount -o remount,rw / and then passwd to change the root password and then reboot again.
- Restart the server.
- As soon as the boot process starts, press ESC to bring up the GRUB boot prompt. You may need to turn the system off from the control panel and then back on to reach the GRUB boot prompt.
- You will see a GRUB boot prompt - press E to edit the first boot option. (If you do not see the GRUB prompt, you may need to press any key to bring it up before the machine boots)
- Find the kernel line (it starts with linux /boot/) and add init=/bin/bash at the end of the line.
- Press CTRL+X or F10 to boot.
- The system will boot and you will see the root prompt. Type mount -o remount,rw / and then passwd to change the root password and then reboot again.
- Load microSD card into another device and append init=/bin/sh to the end of cmdline.txt
- insert the card back into the Pi again and boot up
- When prompt available, enter su to log in as root with no password.
- Run passwd to change the password for the root user.
- If an error is reported, reference Errors
- Shut down/reboot the server and revert changes made to put the server into Single User Mode.
- passwd: Authentication token manipulation error