Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to Reset a Forgotten Root Password on Rocky or AlmaLinux

This guide shows how to get back into your server when you forget the root password. It needs console access to the server, such as a VPS console or a screen on the machine.

How-To Guides2 min read13 steps5 screenshots

What is happening here?

Root is the all-powerful user on a Linux server. If you forget its password, you can still reset it. You restart the server and stop it during the boot menu. Then you open a small repair shell and set a new password. You must be at the server's console, not on SSH, because SSH needs the password you lost. Your VPS panel or the Hostvento client area at the client area may offer a console. If not, ask support.

Warning: follow the steps exactly. Take a snapshot or backup first if your plan allows it.

Steps

  1. Open the server console.
  2. Restart the server. Use the reboot option in your panel, or send Ctrl + Alt + Del.
  3. When the boot menu (called GRUB) appears, press e on the first entry to edit it. Be quick, as it only waits a few seconds.
    Editing the Kernel Parameters
  4. Find the line that begins with linux. Use the arrow keys to go to its end.
  5. Add this at the end of the line, after a space:
    rd.break enforcing
rd.break

This stops the boot early, before the full system starts.

  1. Press Ctrl + X to boot with the change.
  2. A shell prompt appears. Make the system disk writable:
mount -o remount,rw /sysroot
  1. Switch into the real system:
chroot /sysroot
  1. Set a new password:
    sysroot
    passwd root
passwd root

Type the new password twice. Nothing shows while you type. That is normal.

  1. Tell the system to relabel files at next boot. SELinux is a security guard that needs this:
    autorelabel
touch /.autorelabel
  1. Leave the shell, twice:
exit
exit
  1. The server reboots. The first boot is slow because it relabels files. Let it finish.
  2. Log in as root with your new password.
Tip: Some VPS panels have a built-in password reset button. Look there first, or ask Hostvento support. Store your new password in a password manager.

Quick recap

  • You need the server console, not SSH.
  • Edit the boot entry and add rd.break.
  • Remount, chroot, run passwd root.
  • Create /.autorelabel and reboot.