• 8 September 2024

If an Instance with Linux operating system is active in the cloud server section and you forget your user password to enter the Instance environment, you can recover the root password. To do this, you need to click on the “console” option in front of the desired Instance name.

This article discusses the method of recovering the root password in Ubuntu, CentOS, and Debian operating systems.

Ubuntu Operating System

  1. After selecting the console option, restart the operating system using the Alt+Ctrl+Del buttons, and as soon as the window opens and before the operating system is loaded, press the Shift key to enter the GNU GRUB menu.
  2. Using the arrow keys on the keyboard, go to Advance options for Ubuntu and press enter to move to the next step. In this step, choose the second option that ends in recovery mode.
  3. After a few seconds, you will see a page similar to the image below. Select the root option to proceed to the next step.
  4. At this point, press enter to go to the root environment.
  5. Then enter the following command:
  6. In the next step, enter the following command and set a new password.
  7. Finally, restart the Instance with the reboot command.

Note: If you have set a password for the root user of your Ubuntu Instance, you must use the password recovery method in the Debian operating system described below.

Debian Operating System

  1. After selecting the console option from the operation menu, restart the operating system using the Alt+Ctrl+Del buttons and press the “e” key as soon as the window opens and the connection is established to go to the GNU Grub menu. Then, using the arrow keys on the keyboard, go to the line linux /boot/vmlinuz-… and delete all the statements in this line that begin with a console word. In the next step, go to the end of this line and add init=/bin/bash after putting a space. Finally, press Ctrl+X to reboot the system.
  2. After the system is booted, you should move to the following environment.
  3. In this environment, the file system is in read-only mode; to change this file, it must first be transferred to read-write mode. To do this, use the following command:
  4. Now, you can change the root password with the passwd command.
  5. Reboot the system by pressing the Alt+Ctrl+Delete button at the top of the window.

 

Centos Operating System

  1. After selecting the console option from the operation menu, restart the operating system using the Alt+Ctrl+Del buttons and press the “e” key while booting to the following options to go to the GNU Grab menu.
  2. Then, using the arrow keys on the keyboard, go down until you reach the Linux 16 line. Remove all statements on this line that begin with a console word. Change the “ro” in this line to “rw” and add “rd.break enforcing=0” to this line. Finally, press Ctrl+X to reboot the system.
  3. In the next step, transfer the file system to read-write mode using the following command.
  4. Change the root file system using the following command:
  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 (Linux kernel security module) to match these new changes.
  7. Finally, exit the chroot using the exit command. Then use the exit command again to reboot the system.