dkcbk
Flight Engineer
Flight Engineer
  • 17K Views

Reset forgotten root password in RHEL9

Jump to solution
Hi.
Can someone please describe which is the correct way to reset forgotten root password in RHEL9? As someone mentioned in some other post, rd.break method doesnt work in RHEL9.
Tnx
Labels (1)
1 Solution

Accepted Solutions
Tracy_Baker
Starfighter Starfighter
Starfighter
  • 13.8K Views

rd.break does not work in RHEL 9.0. It works in 9.1, 9.2, etc.

For RHEL 9.0:

1: reboot the system. When the grub bootloader screen appears, use the UpArrow and DownArrow keys to stop the countdown timer. Be very quick, as the timer can be set anything from 1 to 5 seconds.

2: On the linux line: Remove all console=  and vconsole=  key=value pairs, if they exist (common in VM installations). Add init=/bin/bash to the end of the line. Press Ctrl x to continue.

3: At the bash-5.1# prompt, enter the mount -oremount,rw / command to remount the system’s root as read/write.

4: Enter the passwd root command to change root’s password

5: Enter the touch /.autorelabel command. Do not typo this command or you get to start over (we call that practice).

6: Enter the /usr/sbin/reboot -f  command to reboot the system.

---

The system will now reboot and relabel (because of the existence of the /.autorelabel file from step 6) all the directories and files in the filesystem. It can take a long time (especially if there are lot of objects on the system).

The system will delete /.autorelabel file and reboot again, normally.

At this point, you should be able to log in as root using the password you’ve set.

Program Lead at Arizona's first Red Hat Academy, est. 2005
Estrella Mountain Community College

View solution in original post

24 Replies
Tracy_Baker
Starfighter Starfighter
Starfighter
  • 13.8K Views

rd.break does not work in RHEL 9.0. It works in 9.1, 9.2, etc.

For RHEL 9.0:

1: reboot the system. When the grub bootloader screen appears, use the UpArrow and DownArrow keys to stop the countdown timer. Be very quick, as the timer can be set anything from 1 to 5 seconds.

2: On the linux line: Remove all console=  and vconsole=  key=value pairs, if they exist (common in VM installations). Add init=/bin/bash to the end of the line. Press Ctrl x to continue.

3: At the bash-5.1# prompt, enter the mount -oremount,rw / command to remount the system’s root as read/write.

4: Enter the passwd root command to change root’s password

5: Enter the touch /.autorelabel command. Do not typo this command or you get to start over (we call that practice).

6: Enter the /usr/sbin/reboot -f  command to reboot the system.

---

The system will now reboot and relabel (because of the existence of the /.autorelabel file from step 6) all the directories and files in the filesystem. It can take a long time (especially if there are lot of objects on the system).

The system will delete /.autorelabel file and reboot again, normally.

At this point, you should be able to log in as root using the password you’ve set.

Program Lead at Arizona's first Red Hat Academy, est. 2005
Estrella Mountain Community College
dkcbk
Flight Engineer
Flight Engineer
  • 13.8K Views
Thank you. But it does not work for me. After completing first step, ctrl+x gives me black screen (the same as with rd.break method). The only thing I can do is to power off VM.
Tracy_Baker
Starfighter Starfighter
Starfighter
  • 13.7K Views

I can assure it it does work as I've just done it again.

Did you make certain to do Step 2?

2: On the linux line: Remove all console=  and vconsole=  key=value pairs, if they exist (common in VM installations). Add init=/bin/bash to the end of the line. Press Ctrl x to continue.

What's your grub look like? Perhaps take a screenshot and post it?

Program Lead at Arizona's first Red Hat Academy, est. 2005
Estrella Mountain Community College
dkcbk
Flight Engineer
Flight Engineer
  • 13.7K Views

I tried it in RH134 course lab and both methods work (rd.break and init=/bin/bash).
It seems that issue is only in my home lab.
Thank you again.

fortunehr
Mission Specialist
Mission Specialist
  • 10.3K Views
do you use a macbook ?
0 Kudos
Sushankumar
Mission Specialist
Mission Specialist
  • 13.5K Views
Informative thanks it worked.
dkcbk
Flight Engineer
Flight Engineer
  • 13.5K Views
I took the exam a week ago (RHEL9). I used rd.break method. There were no problems with this method.
Sushankumar
Mission Specialist
Mission Specialist
  • 13.5K Views
Not sure why it didn't work for me.
rd.break is what I have practiced 100+ times...
khokha
Flight Engineer
Flight Engineer
  • 13.4K Views

Hi @Tracy_Baker , I reserveed my RHCSA exam but didn't find newer versions than v9.0 for the exam, so the rd.break method won't work in the exam environment?

Thanks in advance

0 Kudos
Join the discussion
You must log in to join this conversation.