How to Reset the Root Password in Linux

04 Nov 2026, 07:05:02
A forgotten root password is not a reason to reinstall the operating system or lose your data. In most cases, access to a Linux server can be restored by resetting the password through Recovery Mode, GRUB, or a LiveCD.
The recovery method depends on the Linux distribution, bootloader configuration, and availability of access to the server console.

1. Resetting the password through the VPS control panel

If you use our VPS services, you can automatically reset the password directly from the service management page.
This method does not require access to the operating system via SSH or the console.

Step 1. Open the service management page

Log in to your client area and open the management page for the required VPS.

Step 2. Reset the password

Find the server management details section and click the Password Reset button.
The system will automatically generate a new root password and update the access credentials displayed on the service page.

Step 3. Retrieve the new password

Click Show Password to view the generated password.

Step 4. Connect to the server

Use the new password to connect to your VPS via SSH:
ssh root@SERVER_IP

2. Resetting the password through GRUB

One of the most common methods is to boot the system in single-user mode using GRUB.
This method works with most servers running Debian, Ubuntu, and other Linux distributions that use GRUB2.

Step 1. Open the server console

For a VPS, use VNC or another available remote console. For a dedicated server, you can use IPMI, iDRAC, iLO, or KVM-over-IP.
Reboot the server and wait for the GRUB menu to appear.

Step 2. Modify the boot parameters

In the GRUB menu, select the required Linux kernel and press e to edit the boot parameters.
Find the line starting with:
linux /boot/vmlinuz...
Locate the ro parameter and replace it with rw init=/bin/bash.
Press Ctrl + X or F10 to continue booting.

Step 3. Reset the root password

After booting, you will be taken to a command shell with superuser privileges.
Run:
passwd rootEnter the new password and confirm it.

If the filesystem was mounted in read-only mode, remount it with write access first:
mount -o remount,rw /

Step 4. Reboot the server

After successfully changing the password, run:
sync
reboot -f
After the reboot, try logging in using the new password.

3. Resetting the password through Recovery Mode

Ubuntu includes a built-in recovery mode that allows you to obtain root access without entering the old password.
  1. Reboot the server.
  2. Open the GRUB menu.
  3. Select Advanced options for Ubuntu.
  4. Select the kernel marked (recovery mode).
  5. In the recovery menu, select root — Drop to root shell prompt.

Once the command prompt appears, remount the root filesystem with write access:
mount -o remount,rw /Reset the root password:
passwd rootEnter the new password and confirm it.
Once finished, you can continue with a normal boot:
sync
reboot
This method is suitable for Ubuntu systems where Recovery Mode is available.
However, there is an important caveat: if selecting root — Drop to root shell prompt immediately prompts you for the root password, this recovery method will not help if the password has been forgotten.

4. Resetting the password through LiveCD

If GRUB is unavailable or booting into Recovery Mode is not possible, you can use a LiveCD.

Step 1. Boot from LiveCD

Attach a Linux ISO image on the server management page and follow the instructions for booting a VM from an ISO image.

Open the VNC console and select Live system.

Step 2. Identify the system partition

After the system boots, run:
lsblk -fThis command displays a list of disks, partitions, filesystems, and mount points.

Step 3. Mount the system partition

Create a mount point:
mkdir -p /mnt/sysrootMount the partition:
mount /dev/sda2 /mnt/sysroot

Step 4. Enter chroot

Prepare the necessary system directories:
for dir in dev proc sys run; do
    mount --rbind /$dir /mnt/sysroot/$dir
    mount --make-rslave /mnt/sysroot/$dir
done
Enter the installed system:
chroot /mnt/sysroot /bin/bashCommands will now be executed within the environment of the installed operating system.

Step 5. Change the password

Run:
passwd rootEnter the new password and confirm it.
After that, exit chroot:
exitUnmount the system partitions:
umount -R /mnt/sysroot
Then, on the server management page, detach (eject) the ISO image and boot the server from its disk.
After the server boots, try connecting using the new password.

5. What if root is disabled on the server running Ubuntu?

In Ubuntu, the root account may be locked by default, preventing direct login using a password.
Administrative operations are performed using a regular user account with sudo privileges.
If you have access to such an account, simply run:
sudo passwd rootYou can then set a new root password.
If you have also forgotten the regular user's password, use one of the recovery methods described above.

6. What to do if access cannot be restored?

In some cases, standard recovery methods may not work.
Possible reasons include:
  • GRUB is password-protected.
  • The system disk is encrypted using LUKS.
  • A non-standard bootloader, such as systemd-boot, is used.
  • The filesystem is corrupted.
  • There is no access to the server console or recovery environment.
If the system disk is encrypted, you will need the encryption key or passphrase to access its contents. Resetting the root password alone does not remove disk encryption.
In such cases, you must first restore access to the boot environment and system partition.

Conclusion

In most cases, a forgotten root password can be reset without reinstalling the operating system or losing user data.
You can use Recovery Mode, modify GRUB boot parameters, or boot from a LiveCD.
The appropriate method depends on the server configuration and the recovery tools available.

VPS in the Netherlands

Browse Configurations

SSD Storage VPS

Browse Configurations