CityHost.UA
Help and support

Resetting the root password through Recovery Mode (Ubuntu / Debian)

This instruction will help you recover the user root password if you have lost it.

Suitable for Ubuntu and most cases for Debian. It can also be used on Dedicated Server via IPKVM or Recovery Mode.

 

!Helpful tip: Before starting manual recovery, try using our new feature — [Automatic password reset for virtual server (VPS/VDS) via control panel]. This will allow you to change the password with one click without rebooting into Recovery Mode. If this method did not work or gave a compatibility error, proceed to the steps below.

 

1. Connecting to the server via VNC

First, you need to connect to the server via the VNC console.

This is necessary because SSH access without a password will be impossible.

 

  • • WEB VNC in the control panel
  • •  or a separate VNC client

 

 

2. Rebooting the server and entering GRUB

In the open VNC console:

 

  1. Press Ctrl + Alt + Del to reboot the server
  2. Immediately after this, start pressing or holding the Esc key (for UEFI)

This is needed to open the GRUB boot menu.

 

 

3. Starting Recovery Mode

In the GRUB menu:

 

  1. Select Advanced options for Ubuntu
  2. Then select the option marked (recovery mode)

After this, the recovery menu will open.

4. Attempt to enter root shell

In the menu, select: Drop to root shell prompt

 

  • •  If the password is not requested  proceed to the next step
  • •  If the system asks for the root password  perform step 5

5. If the system asks for a password (editing GRUB)

If access to the root shell is blocked, you can change the boot parameters:

 

  1. Reboot the server again
  2. In the GRUB menu, select the normal boot of Ubuntu
  3. Press the e key (edit)

 

 

Find the line: linux /boot/vmlinuz...

In this line, replace ro with rw and add at the end: init=/bin/bash

Example: linux /boot/vmlinuz-... root=UUID=... rw init=/bin/bash

 

 

Then press Ctrl + X or F10 to start. The system will boot into the root console without a password.

6. Changing the root password

After booting, you will see something like: root@(none):/#

Execute the command: passwd root  and enter the new password twice.

 

 

7. Rebooting the server

After changing the password, execute reboot -f

Done! The root password has been successfully changed. You can now log into the server with the new credentials.


Similar articles