• 8 September 2024

If a Linux-based instance is active in the Cloud Computing section and for any reason you have forgotten your user password to sign in to the instance environment, you will be able to recover the root password. To do this, you need to use the Console option in “Cloud Compute” -> “Instances -> “Action” menu.

In this topic, the methods of recovering the root password in operation systems of Ubuntu, CentOS, and Debain are described.

Ubuntu operating system

  1. After selecting the console option, as soon as the window opens and before the operating system loads, press Shift to move to the GNU GRUB menu.

  2. Use the arrow keys on the keyboard to go to Advance options for Ubuntu and press Enter to move to the next step. In this step, select the second option that ends with recovery mode.

  3. After few seconds, you will face with a page similar to the image below. Select the root option to move to the next step.

  4. In this step, press Enter to enter into the root environment.

    1. Then, enter the following command:

      mount -o remount,rw /sysroot 

    2. In the next step, enter the following command and set a new password.

      passwd root

    3. Finally, reboot the cloudlet by using the reboot command.

Debian operating system

  1. After selecting the console option from the Operation menu, as soon as the window opens and connection is established press e to move to the GNU Grab menu. Then, using the arrow keys on the keyboard, move to the line of inux / boot / vmlinuz … and delete all phrases in this line beginning with console. In the next step, go to the end of this line and after pressing one Space, add the phrase of init=/bin/bash. Finally, press Ctrl + X to reload the system.

  2. After the system was booted, you should be transferred to the following environment.

  3. In this environment, the file system is in read-only mode. To be able to create any change in this file, it must be first change to read-write mode. To do this, enter the following command:

    mount -o remount /

  4. Now you can change the root password by using the passwd command.

  5. Finally, reboot the system by pressing Alt + Ctrl + Delete at the top of the window.

CentOS operating system

  1. After selecting the Console option from the Operation menu, when you saw the following options during the boot process, press e to move to GNU Grab menu.

  2. Then, using the arrow keys on the keyboard, move down to arrive at Linux 16 line. Delete all phrases in this line beginning with console. Change the phrase of ro in this line to rw, and add the phrase of break enforcing=0 to this line. Finally, press Ctrl + X so the system will be reloaded.
  3. In the next step, using the following command, change the file system to read-write mode:

    mount -o remount,rw /sysroot

  4. Change the root file system using the following command:

    chroot /sysroot

  5. Now, using the passwd command, change the root password and set a new password.

  6. Then, use the following command to update the content of SELinux (a Linux security module) in accordance with these new settings.

  7. Finally, first exit from chroot using the exit command. Then, use the exit command again to reboot the system.