In advanced Linux distributions like AlmaLinux, one of the most common problems faced by virtual server (VDS) administrators is forgetting the root password. However, there is no need to worry; if you can access your server via physical console or VNC, you can reset your password in a few minutes.
Step 1: Reboot the Server and Enter the GRUB Menu
First, log in to your VDS server panel (e.g., the console application in our customer panel) and issue a 'Restart' command to your server. When the server is booting up, use the arrow keys in the GRUB menu that appears to hover over the top AlmaLinux kernel and press the 'e' key on your keyboard.
Step 2: Edit the Boot Parameters
On the editing screen that opens, go down with the arrow keys and find the line starting with linux (or linux16). Go towards the end of this line and find the phrase ro (read-only). Delete this phrase and write the following parameter instead:
rw init=/sysroot/bin/sh
After making the edit, press Ctrl + X to start the system with these settings.
Step 3: Access Sysroot and Change the Password
The system will open in the emergency shell. We are now in a writable environment, not read-only. Now we need to switch to the root directory of our actual system:
chroot /sysroot
Now you can set your new password. Type the following command and press enter:
passwd root
You will be asked for your new password on the screen. Enter a strong password (it will not appear on the screen as you type, this is normal) and press enter. Then enter it again to verify the password.
Step 4: Update SELinux Labels and Reboot
If SELinux is active (which is always recommended in Turkey VDS and enterprise hosting infrastructures), you must create the following hidden file to ensure that file labels are reconfigured:
touch /.autorelabel
Process completed! Now we can exit the chroot environment and reboot the server normally:
exit
reboot
When your server boots up, you can log in with your new root password. If you do not want to waste time doing such operations manually, do not forget that you can use the "One-Click Password Reset" feature via the control panel offered in İyibirNet's professional rent virtual server service!