Easy Steps To Reset Root Password on Rocky Linux 9
In this guide, we intend to teach you How To Reset Root Password on Rocky Linux 9. If you need to log in as a root user on your Rocky Linux 9 system after some time and can’t remember its password, the only method to recover is to reset it. To do this, follow the steps below on the Orcacore website.
In this article, we will guide you on how to Reset Root Password on Rocky Linux 9 from the GRUB menu. The GRUB menu is a boot loader and software that loads and transfers control to an operating system, such as Linux, when a computer is turned on. Losing access to the root account can be a major hurdle, and knowing how to regain control is crucial for system administrators and users alike. This article provides a straightforward method to regain access.
First, you need to restart your system, and while doing that press and hold the Shift key on your Keyboard. This will drop you into the Grub menu of Rocky Linux 9. The timing can be a little tricky; you might need to try a few times to catch the GRUB menu before the system boots completely.
Next, you need to press the ‘e’ key on your keyboard. This will let you edit the Grub’s boot prompt. Don’t touch or delete anything here. Once you have the editor move to the next step. Accidentally modifying the boot configuration can prevent the system from starting, so proceed with caution.
At this point, use your arrow key and move to the end of the line starting with “Linux”. After the root ro line, type rw init=/bin/bash. This tells the system to boot into a bash shell with root privileges, bypassing the normal login process.
rw init=/bin/bash

After adding the syntax, boot your system with this configuration. To do this, you can use Ctrl+X or F10. This will start the system with the modified boot parameters.
2. Root Shell Access on Rocky Linux 9
At this point, without providing any password you will have a Rocky Linux 9’s shell with root access. You’ve effectively bypassed the normal login procedure and gained administrative privileges.
First, let’s check whether your user has read and write access to the file system where the OS has been installed. This is important to ensure you can actually modify the root password.
To do this, run the following command:
mount | grep -w /
If you see (rw,realtime) in your output, it means you have real-time read and write access to the file system. If you don’t see "rw," it indicates the filesystem is mounted read-only. In this case, you’ll need to remount it with read-write permissions before proceeding. This can be done with the command mount -o remount,rw /
.
3. Change Root Password on Rocky Linux 9
Now you can simply Change Root Password on Rocky Linux 9 with the following command:
passwd
The system will prompt you to add a new password two times. Ensure you choose a strong and memorable password.
To change the password of some other user than root, we have to mention the username of the same. The syntax is like the following command:
passwd <mark>username</mark>
This is useful if you’ve forgotten the password for another user account on the system.
When you are done resetting your Linux password, restart your system to log in with the changed password. For rebooting, run the command below:
exec /sbin/init
After that, hit the Enter key. This command initiates the system’s initialization process, effectively rebooting the machine.
From here, you can log in and access your system with the newly set root password. Keep the new password in a safe place!
Conclusion
At this point, you have learned to Reset or Recover the Lost or Forgotten Password on Rocky Linux 9 from the Grub Menu. Hope you enjoy it. Please subscribe to us on Facebook, YouTube, and X.
You may like these articles:
- Fix phpMyAdmin SSL Error Connection
- Change LiteSpeed WebAdmin Console Login
- How To Install WineHQ on Rocky Linux 9
FAQs
How do I access the GRUB menu on Rocky Linux 9?
Restart your system and press the Esc or Shift key repeatedly during boot to access the GRUB menu.
Can I reset the root password without booting into GRUB?
No, you must access GRUB to enter an emergency mode for a password reset.
Will resetting the root password affect my data?
No, resetting the root password does not affect your files or settings.
Alternative Methods to Reset Root Password on Rocky Linux 9
While the GRUB method is a common and effective way to reset root password on Rocky Linux 9, there are alternative approaches you can take. Here are two different methods:
1. Using a Rescue Disk or Live Environment:
This method involves booting your Rocky Linux 9 system from a rescue disk or a live Linux environment (like a Rocky Linux installation disk or USB). This allows you to access the system’s files without needing the root password.
-
Explanation: Booting from external media bypasses the normal system startup, allowing you to mount the root filesystem and modify the password file. This is particularly useful if GRUB is inaccessible or corrupted.
-
Steps:
-
Boot from the rescue disk or live environment: Configure your BIOS or UEFI settings to boot from the CD/DVD drive or USB drive containing the rescue disk or live environment.
-
Identify the root partition: Once booted into the rescue environment, you need to identify the partition where your Rocky Linux 9 system is installed. You can use the
lsblk
command to list the available block devices and their partitions.lsblk
Look for the partition that is likely the root partition (usually labeled
/
or containing the/boot
directory). -
Mount the root partition: Create a mount point and mount the root partition. Replace
/dev/sdaX
with the actual partition you identified in the previous step.mkdir /mnt/sysroot mount /dev/sdaX /mnt/sysroot
-
Chroot into the mounted system: Use the
chroot
command to change the root directory to the mounted system. This allows you to execute commands as if you were running within the original Rocky Linux 9 environment.chroot /mnt/sysroot
-
Reset the root password: Now you can use the
passwd
command to reset the root password.passwd
Enter the new password when prompted.
-
Exit the chroot environment and unmount the partition: After resetting the password, exit the
chroot
environment and unmount the root partition.exit umount /mnt/sysroot
-
Reboot the system: Reboot your system and log in with the newly set root password.
-
2. Utilizing Single User Mode (if enabled):
If single-user mode is enabled and not password-protected, you can boot into it directly and reset the password. However, modern systems often disable or password-protect single-user mode for security reasons.
-
Explanation: Single-user mode provides a minimal environment with root access, typically used for system maintenance and recovery. If accessible, it offers a direct way to change the root password.
-
Steps:
-
Interrupt the boot process: During boot, interrupt the process (usually by pressing Esc or any other specified key) to access the GRUB menu.
-
Edit the boot entry: Similar to the GRUB method, press ‘e’ to edit the selected boot entry.
-
Add
single
or1
to the kernel line: Locate the line starting withlinux
orlinuxefi
and add the wordsingle
or the number1
at the end of the line. This instructs the kernel to boot into single-user mode.linux /boot/vmlinuz-5.14.0-284.11.1.el9_2.x86_64 root=UUID=your-uuid ro single
-
Boot the system: Press Ctrl+X or F10 to boot the system with the modified boot parameters.
-
Reset the root password: You will be presented with a root shell without needing to log in. Use the
passwd
command to reset the root password.passwd
Enter the new password when prompted.
-
Reboot the system: Reboot the system to log in with the newly set root password.
reboot
-
Remember to always exercise caution when modifying boot configurations or system files. Incorrect changes can lead to system instability or data loss. Always back up important data before attempting these procedures. These methods offer alternative ways to reset root password on Rocky Linux 9, providing flexibility in different recovery scenarios. The best method to reset root password on Rocky Linux 9 depends on your specific situation and system configuration.