Access Single User Mode - Reset Root Password in Linux 


For resetting the root password of the server there will be a need to boot into a single user mode. Accessing the manage section of the server in the customer portal and then following these steps. The option depends on the bootloader version of the machine:

CentOS 6

  • Clicking the [View Cosole] for accessing the console and then click the send CTRL+ALT+DEL button on the top right. You will also be able to click the RESTART for restarting the server. The option depends on the bootloader version on the machine.
  • After clicking it you will be able to see the GRUB boot prompt which will tell you to press any of the keys, you will only be having few seconds for pressing a key for stopping the automated booting process.
  • At the GRUB prompt you need to type an “a” for appending the boot command.
  • Now you need to text “single” and then you have to press enter.
  • Now the system will be able to see the root prompt. Type “passwd” for changing the root password and then rebooting it again.


CentOS 7

  • Click on the [View Console] for accessing the console and then click the send CTRL + ALT + DEL button which is on the top right. You will also be able to click the [RESTART] for restarting the server.
  • As soon as the boot process starts press ESC for bringing up the GRUB boot prompt. You might need to turn the system off from the control panel then back on the reach for the GRUB prompt.
  • Now you will be able to see a GRUB boot prompt - press “e” for editing the first boot option.
  • Now you need to find the kernel line (starts with “linux”), change ro to rw init=/sysroot/bin/sh.
  • Now you have to Press CTRL-X or F10 for booting the single user mode.
  • Accessing the system with command chroot/sysroot.
  • Now you need to run the passwd for changing the root password.
  • Reboot the system: reboot -f.
 

Debian, Ubuntu

  • Click on the [View Console] for accessing the console and then clicking on the send CTRL+ALT+DEL button on the top right. You can also click on the [RESTART] for restarting the server.
  • Once the boot process starts, you need to press the ESC for bringing up the GRUB boot prompt. You will have to turn off the system from the control panel and then back on to reach the GRUB boot prompt.
  • Now you will see a GRUB boot prompt - press “e” for editing the first boot option.
  • Now you need to find the kernel line (starts with “linux/boot”) and then add init=”/bin/bash” at the end of the line.
  • Now you need to CTRL-X or F10 for booting.
  • Now the system will boot and you will be able to see the root prompt. Now you need to type “mount -rw -o remount /” and then “passwd” for changing the root passwd and then rebooting it again.
 

FreeBSD

The boot menu is having an option for booting into a single user mode. Now you have to press the key for a single user mode.
At the root, type “passwd” for changing the root password and then rebooting it again.

CoreOS

CoreOS by default uses an SSH key authentication. At HostingRaja the root user as well as the password will be created. If an SSH key will be selected while creating the VPS, then this SSH key will be used to login as the user “core”.

It is possible for resetting the standard root login by executing the “sudo passwd” as user “core”. Login in as the “core” by using the SSH key at first instance.

If you have lost the SSH key, then you will be able to login as the “core” user by editing the grub loader. Some of the steps to be followed are:

  • Clicking on the [View Console] for accessing the console and then clicking on the send ctrl+alt+del button on the top right corner. You will also be able to restart the server.
  • You will be able to see the GRUB boot prompt - press “e” for editing the first boot option. If you are not able to see the GRUB prompt then you will have to press the any key for bringing up before the machine boots.
  • Now at the end of the line which will begin with “linux$” add” coreos.autologin=tty1” (no quotes).
  • Now you need to Press the CTRL-X or F10 for booting. Then you will be logged in as “core” when the system is booting.
  • Always remember to reboot the the server after resetting the login.