Back

Ubuntu 18.04 - 24.04 - Root password reset

General information

If you have lost the root user password and cannot log in, this guide will help you reset it.

To reset the password, you will need console access to the server. Go to the Customer portalServer pageVNC Console. This provides direct access to the server's console, even if SSH is unavailable.

To reset the password:

  1. Reboot the server
  2. Edit the kernel boot parameters using the GRUB bootloader
  3. Boot into single-user mode
  4. Set a new root password without entering the previous one
  5. Reboot the server

The reboot and shutdown -r, commands, as well as the Ctrl+Alt+Del button, will not work at this stage, as they rely on the init daemon, which will be replaced with /bin/bash.
Use the reboot -f command or manually start init using exec /sbin/init.

Resetting a password on a dedicated server

To reset the root user password, complete the following steps:

  1. Reboot the server
    • Open the customer portal, navigate to the server page, and launch the VNC Console
    • In the VNC Console toolbar, click Send CtrlAltDel to reboot the server
launch the VNC console

After the BIOS screen, the GRUB boot menu will appear

GRUB boot menu
  1. Edit boot parameters
    • Use the and arrow keys to select the boot entry for your operating system (usually *Ubuntu)
    • Press e to edit the selected entry
Edit boot parameters
  1. Boot into single-user mode
    • Locate the line starting with linux /vmlinuz
    • Replace the ro parameter to rw
    • At the end of the line, add init=/bin/bash
boot into single user mode
    • Press Ctrl+Xor F10 to boot with the modified parameters
    • Use the on-screen buttons in the VNC Console to send key combinations:
Boot with modified parameters

The system will boot directly into a console without requiring login credentials

System will boot directly into a console
  1. Reset the root password
    • Once the system boots into a shell prompt, run:
      passwd root
    • Enter a new root password twice when prompted
  2. Save changes and reboot the server
    • In the console, run these commands:
      sync
      reboot -f

Once the system reboots, you can log in as root using the new password.

Suggested Articles

  • Dedicated servers

    How to set up L2TP over IPsec for iDRAC on Linux Ubuntu 20.04

  • Dedicated servers

    How to set up L2TP over IPsec for iDRAC on Linux Ubuntu 18.04