How to recover the root password on ubuntu server [duplicate]
I lost my root/super user password on Ubuntu server.
I tried to boot in a recovery mode and select option drop to root shell
.
But it is always asks for:
Give root password for maintenance (or type Control-D to continue)
and I don't remember it.
Solution 1:
Try Control-D when it prompts you for the root password. If that doesn't work, then try this:
http://www.howtogeek.com/howto/linux/reset-your-forgotten-ubuntu-password-in-2-minutes-or-less/
Then scroll down to "Alternate Root Shell Method".
Solution 2:
- Click [View Console] to access the console and click the send CTRL+ALT+DEL button on the top right. Alternatively, you can also click [RESTART] to 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 (starts with
linux /boot/
) and addinit="/bin/bash"
at the end of the line.- Press CTRL-X or F10 to boot.
- System will boot and you will see the root prompt. Type
mount -rw -o remount /
and thenpasswd
to change the root password and then reboot again.
Reference: https://www.vultr.com/docs/boot-into-single-user-mode-reset-root-password