RHEL 9 Root Password Recovery: Your Quick & Easy Solution to Regain Access
If you’ve lost your root password on RHEL 9 and can no longer access root privileges, there’s no need to panic. Follow these steps to reset…
RHEL 9 Root Password Recovery: Your Quick & Easy Solution to Regain Access
If you’ve lost your root password on RHEL 9 and can no longer access root privileges, there’s no need to panic. Follow these steps to reset your root password and regain access.
Step 1: Reboot the System and Access the GRUB Boot Loader
If you’re logged in via another user account (not as root), you can reboot the system using the following command
cmd$ reboot
When the GRUB boot loader menu appears, quickly press e on your keyboard to edit the boot parameters.
This will take you to the GRUB edit screen, where you can modify the boot sequence.
Step 2: Modify the Boot Sequence
- In the GRUB edit screen, locate the line that starts with
linuxorlinux16. This is usually the second last line on the screen. - At the end of this line, add the following parameters:
Add at then end of second last like rd.break enforcing=0
rd.break enforcing=0
enforcing=0 will disale the SELinux.
rd.break pauses the boot process and loads you into the RAM disk (initramfs), allowing you to modify system files.
After adding the parameters, press Ctrl + X to boot with the modified parameters.
This will take you to a shell prompt labeled switch_root:#.
Step 3: Remount /sysroot with Read and Write Privileges
At the shell prompt, remount the /sysroot directory with read and write privileges using the following command
mount -o remount,rw /sysroot
Step 4: Change the Apparent Root Directory to /sysroot
Change the root directory to /sysroot by running:
chroot /sysroot
stpe5: Reset root password
Now we can rest the root passwod via the following command
passwd root
step 6 Exit & login
reboot your system and login with root account
Step 7: Restore SELinux Context for /etc/shadow
After logging in as root, you need to restore the SELinux context for the /etc/shadow file by running:
restorecon /etc/shadow
This step ensures that the SELinux policy is correctly applied to the password file.
Thank you
Hope you like it
메타데이터
- post_id
- e3014da59c1b
- slug
- rhel-9-root-password-recovery-your-quick-easy-solution-to-regain-access-e3014da59c1b
- url
- https://medium.com/@tonystark83033/rhel-9-root-password-recovery-your-quick-easy-solution-to-regain-access-e3014da59c1b
- canonical_url
- https://medium.com/@tonystark83033/rhel-9-root-password-recovery-your-quick-easy-solution-to-regain-access-e3014da59c1b
- author_url
- https://medium.com/@tonystark83033
- status
- ok
- fetched_at
- 2026-08-10 18:06:31