How to reset the root password for your Self-Managed server

This article explains how to reset the root password on an AlmaLinux system when access is lost. This method requires booting into emergency mode using the GRUB bootloader and performing the reset from a restricted shell environment.

Step 1: Access the Server Console (VNC)

  1. Log in to https://my.hosting.com/

  1. Go to Products and Services -> Hosting and Services


  1. Click on Manage
  1. Click the Login button

Now you are in your Console

Step 2: Boot into GRUB Menu

  1. Reboot the system.

  1. When the GRUB menu appears, select the default kernel entry. You should navigate with the arrows

  1. Press e to edit the boot parameters.

Step 3: Modify Kernel Boot Parameters

  1. Locate the line starting with linux or linuxefi.
  2. At the end of that line, add:
rd.break
  1. Press Ctrl + X (or F10) to boot with the modified parameters.

Step 4: Enter Emergency Mode Shell

After booting, the system will drop into an emergency shell with a prompt similar to:

switch_root:/#

Step 5: Remount the System as Writable

mount -o remount,rw /sysroot

Step 6: Chroot into the Installed System

Switch into the actual system environment:

chroot /sysroot

Step 7: Reset the Root Password

Run the password utility:

passwd root
  • Enter a new password when prompted.
  • Confirm the new password.

Step 8: Enable SELinux Relabeling

❗️

This step should be performed only if you are using AlmaLinux

To ensure proper SELinux context restoration, create the autorelabel file:

touch /.autorelabel

Step 9: Exit and Reboot

Exit the chroot environment and reboot the system:

exit
exit