Recovering the root password in the Recovery mode - ArvanCloud

ArvanCloud Blog

Read more about ArvanCloud news,
updates, products and services in ArvanCloud weblog.

Recovering the root password in the Recovery mode

22 Jul 2019

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.

  1. 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.

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

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

  1. Then, enter the following command:

mount -o remount, rw /

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

passwd root

  1. 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.

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

  1. 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 /

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

  1. 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.

  1. 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.

  1. In the next step, using the following command, change the file system to read-write mode:

mount -o remount,rw /sysroot

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

chroot /sysroot

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

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

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

دیدگاه شما