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
-
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.
- 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.
-
After few seconds, you will face with a page similar to the image below. Select the root option to move to the next step.
-
In this step, press Enter to enter into the root environment.
-
Then, enter the following command:
mount -o remount,rw /sysroot
-
In the next step, enter the following command and set a new password.
passwd root
-
Finally, reboot the cloudlet by using the reboot command.
-
Debian operating system
-
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.
-
After the system was booted, you should be transferred to the following environment.
-
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 /
-
Now you can change the root password by using the passwd command.
-
Finally, reboot the system by pressing Alt + Ctrl + Delete at the top of the window.
CentOS operating system
-
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.
- 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.
- In the next step, using the following command, change the file system to read-write mode:
mount -o remount,rw /sysroot
-
Change the root file system using the following command:
chroot /sysroot -
Now, using the passwd command, change the root password and set a new password.
-
Then, use the following command to update the content of SELinux (a Linux security module) in accordance with these new settings.
-
Finally, first exit from chroot using the exit command. Then, use the exit command again to reboot the system.