cancel
Showing results for 
Search instead for 
Did you mean: 
Denzil
Mission Specialist
Mission Specialist
  • 2,682 Views

How to rest Readhat 8.0 forgotten Root Password.

Jump to solution

I have a multi boot installed in my computer; Linux Readhat 8, Derbian Linux and Ubantu.

Appreciate if you colud assist me how to get into the forgotten root password and reset it.

 

 

Kind Regards,

 

Denzil

Denzil Peiris
Tags (1)
5 Solutions

Accepted Solutions
Travis
Moderator
Moderator
  • 908 Views

@Denzil -

Basically, anything RHEL7 and above you need to interrupt the GRUB boot process and modify the password. Here are two decent examples on what to do with resetting root password on RHEL. Again, you would need to start your boot process with a multi-boot system and then access the correct entry from GRUB.

https://www.redhat.com/en/blog/recover-root-passwd

https://access.redhat.com/solutions/1276063 

Travis Michette, RHCA XIII
https://rhtapps.redhat.com/verify?certId=111-134-086
SENIOR TECHNICAL INSTRUCTOR / CERTIFIED INSTRUCTOR AND EXAMINER
Red Hat Certification + Training

View solution in original post

Travis
Moderator
Moderator
  • 852 Views

@Denzil -

Your screenshot is of a Grub menu, each item there is a boot entry. I would assume since you mentioned RHEL8, that when you attempt to boot the machine in RHEL, you typically go to the RHEL 8 entry there which is Oopta 8.10, as that would be the default RHEL 8 entry for GRUB. 

If that is the case, you would select that line and then choose the "e" so you can edit that GRUB boot entry. Again, you find the line with the Linux kernel options and append the rd.break.

What this does is to break out of the boot process before SELinux loads and. before any of the password things load into the system so you are in a special prompt as the root user (already logged in). That is where the instructions with the chroot and things come into play as you can then reset the root password and set SELinux to autorelabel the system. Keep in mind, it will essentially go through the boot process 2x after you finish. The first is the autorelabel, and the second would be the actual boot. 

Travis Michette, RHCA XIII
https://rhtapps.redhat.com/verify?certId=111-134-086
SENIOR TECHNICAL INSTRUCTOR / CERTIFIED INSTRUCTOR AND EXAMINER
Red Hat Certification + Training

View solution in original post

Travis
Moderator
Moderator
  • 1,164 Views

@Denzil -

At this point with all the posts, I'm somewhat confused. If you made it through the password reset process and used the passwd command, the password was changed on disk. You are correct in that you have a multi-boot system and that it defaults to boot Debian, however, that has no bearing on resetting the password. The autorelabel process will take place and yes you might have missed the boot and it boots to Debian on reboot, but that doesn't mean that RHEL 8.x didn't do its thing. You should be able to select the RHEL 8 entry from the boot menu and begin using it.

It is possible to use another Linux distribution (like Debian) that is installed as dual-boot or even a live boot media like Fedora to boot the system and then mount the RHEL8 drive/partition that contains the filesystem for "/" on RHEL, but you must know what that partition is and how to mount it and perform a chroot to make that the new "/" of the filesystem. It gets more complicated if you are using Logical Volumes (LVM) or have multiple partitions for each filesystem because if you mess up, you could impact both Debian and RHEL. If you already went through the password reset procedure for RHEL8, then /etc/shadow should already be updated with the new password on disk.

In terms of setting a default boot, that could also be more complicated as it involves GRUB. You do have a boot partition that contains GRUB and the GRUB entries, but I'm not exactly sure which distribution made your GRUB menu and where you might easily find the GRUB menu config to change it. Generally, you can use the template to modify the GRUB boot menu configuration and regenerate, but doing it incorrectly would make all Linux distributions unbootable until you got it fixed.

WARNING and Caution if you proceed ...

You need to figure out which Linux distribution is in control of GRUB to modify things easily. 

/boot/grub/grub.cfg  or /boot/grub2/grub.cfg should exist and have the entries for boot. If you used RHEL, the config file to edit would be /etc/default/grub most likely and you would see the entries. You would set the default GRUB entry, and update GRUB. The process is slightly different for Debian vs. Red Hat. Additionally, for RHEL systems, there are 2 commands depending on BIOS or UEFI booting.

BIOS: sudo grub2-mkconfig -o /boot/grub2/grub.cfg

UEFI: sudo grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

Note on UEFI the redhat might be a dfferent name/path for the command. You should be able to find this out looking in the directory before running the command.

Travis Michette, RHCA XIII
https://rhtapps.redhat.com/verify?certId=111-134-086
SENIOR TECHNICAL INSTRUCTOR / CERTIFIED INSTRUCTOR AND EXAMINER
Red Hat Certification + Training

View solution in original post

Travis
Moderator
Moderator
  • 1,006 Views

@Denzil -

Again, there is always a risk of data loss when repartitioning, installing, and formatting if you select the wrong item. The boot menu can be destroyed in that it get re-written, so that could make all installations non-bootable or it could fix everything. Unfortunately, just a partition layout isn't good enough because you also have LVMs in the mix. Without knowing how the systems were installed, you could have a setup like the following:

/dev/sda (1TB)

/dev/sda1 (450GB) - Debian

/dev/sda2 (450GB) - RHEL

/dev/sda3 (5GB) - Boot

The only known thing would be a common boot partition that the BIOS/UEFI would use. The other partitions could be assigned to a PV/VG/LV which could be laid out in any number of ways. Alternatively, if you did things an "old school way" you could have separate partitions for every mount point following good security protocols, meaning you would have a bunch of partitions on the disk and you could potentially have two (2) partitions for /home one that was Debian, and one that is RHEL.

Unfortunately providing exact guidance in a forum like this is dangerous (especially for this) as you could have any setup under the sun and you could be dealing with differences and customizations that no one is aware of or you might have forgotten. The keyboard layout and different keyboards is a great example of how something that was meant to be a quick fix turns complicated very very quickly.

If you know for certain there is nothing you need on the system and can reload Debian and RHEL, it isn't dangerous at all to play with fire, because the worst thing that happens is it burns down and you rebuild with the newest/freshest installation of both (you are only out time). If you have work or critical personal files on the system without a backup, that is something that would be gone with the fire and couldn't be restored.

One final thing I can offer you ... I had suggested you build a Fedora Live USB. It could be used on this system. You can explore the hard drive by booting into Fedora Live. There you have a wonderful graphical interface. It won't mess up anything on your existing drive. It will however provide you a ton of tools and allow you to mount partitions from both Debian/RHEL and explore the filesystem. That will provide an opportunity to copy critical files off the system. If you choose to leverage Fedora Live, you can even connect to the network and copy the files off to a cloud service like Google Drive, Dropbox, OneDrive, etc. (even pushing things up to Github or something), just so you have a copy of your data.

 

Travis Michette, RHCA XIII
https://rhtapps.redhat.com/verify?certId=111-134-086
SENIOR TECHNICAL INSTRUCTOR / CERTIFIED INSTRUCTOR AND EXAMINER
Red Hat Certification + Training

View solution in original post

Travis
Moderator
Moderator
  • 1,012 Views

@Denzil -

So yes, if you have a prompt on the command line in this case if it actually reads bash-x.y# that is a command line prompt and the # indicates it is already "root". Those commands are for keyboard mapping and location. 

$ localectl status
System Locale: LANG=en_US.UTF-8
VC Keymap: us
X11 Layout: us
X11 Model: pc105

Is from my local Fedora system. The $ means I'm a standard user at the prompt. Again, BASH prompts can be customized. Generally on RHEL systems it would be user@hostname $ or something like that.

Travis Michette, RHCA XIII
https://rhtapps.redhat.com/verify?certId=111-134-086
SENIOR TECHNICAL INSTRUCTOR / CERTIFIED INSTRUCTOR AND EXAMINER
Red Hat Certification + Training

View solution in original post

0 Kudos
42 Replies
Travis
Moderator
Moderator
  • 909 Views

@Denzil -

Basically, anything RHEL7 and above you need to interrupt the GRUB boot process and modify the password. Here are two decent examples on what to do with resetting root password on RHEL. Again, you would need to start your boot process with a multi-boot system and then access the correct entry from GRUB.

https://www.redhat.com/en/blog/recover-root-passwd

https://access.redhat.com/solutions/1276063 

Travis Michette, RHCA XIII
https://rhtapps.redhat.com/verify?certId=111-134-086
SENIOR TECHNICAL INSTRUCTOR / CERTIFIED INSTRUCTOR AND EXAMINER
Red Hat Certification + Training
TudorRaduta
Community Manager
Community Manager
  • 893 Views

Great explanation and thanks for sharing these examples on resetting the root password in RHEL, it's super helpful!

0 Kudos
Denzil
Mission Specialist
Mission Specialist
  • 876 Views

Hello Travis,

 

Thank you so much.

I have read both your links, and I am making an attempt to follow https://access.redhat.com/solutions/1276063 

Press e to edit the selected entry>> kindly see the attached. From the menu shoud I choose * Red Hat Enterprise Linux 8.10 Oopta... Or which?Linux_MultiBoot.jpg

As regards to>> (For RHEL8 and RHEL9)

linux ($root)/vmlinuz-4.18.0-372.el8.x86_64 root=UUID=/dev/mapper/vg_rhel-root ro crashkernel=auto  resume=/dev/mapper/vg_rhel-swap rd.lvm.lv=vg_rhel-root rd.lvm.lv=vg_rhel-swap rhgb quiet 

 

 

Kind Regards,

 

Denzil

Denzil Peiris
0 Kudos
Travis
Moderator
Moderator
  • 853 Views

@Denzil -

Your screenshot is of a Grub menu, each item there is a boot entry. I would assume since you mentioned RHEL8, that when you attempt to boot the machine in RHEL, you typically go to the RHEL 8 entry there which is Oopta 8.10, as that would be the default RHEL 8 entry for GRUB. 

If that is the case, you would select that line and then choose the "e" so you can edit that GRUB boot entry. Again, you find the line with the Linux kernel options and append the rd.break.

What this does is to break out of the boot process before SELinux loads and. before any of the password things load into the system so you are in a special prompt as the root user (already logged in). That is where the instructions with the chroot and things come into play as you can then reset the root password and set SELinux to autorelabel the system. Keep in mind, it will essentially go through the boot process 2x after you finish. The first is the autorelabel, and the second would be the actual boot. 

Travis Michette, RHCA XIII
https://rhtapps.redhat.com/verify?certId=111-134-086
SENIOR TECHNICAL INSTRUCTOR / CERTIFIED INSTRUCTOR AND EXAMINER
Red Hat Certification + Training
Travis
Moderator
Moderator
  • 850 Views

I've also included some of my instructor demo pieces (specifically for a RHEL8 installation). If you go to page 27 (printed page) or (31 out of 67 - digitial page), you will see the Reset Root Password procedure. This can be an additional resource to help you.

Travis Michette, RHCA XIII
https://rhtapps.redhat.com/verify?certId=111-134-086
SENIOR TECHNICAL INSTRUCTOR / CERTIFIED INSTRUCTOR AND EXAMINER
Red Hat Certification + Training
Denzil
Mission Specialist
Mission Specialist
  • 821 Views

Hello Travis,

 

Thank you so much! 

 

 

Kind Regards,

 

Denzil

Denzil Peiris
0 Kudos
Denzil
Mission Specialist
Mission Specialist
  • 824 Views

Good day to you Travis,

 

Thank you nd appreciate your professional help.

Once I selct as advised, and press e, I get a screen, and appended init=/bin/bash

(1) This was a success, and I got this prompt root@denzil /]#

However, when I typed; bash-x.y# mount -o remount,rw /

 it said command not found

Appreciate your kind advise.

 

 

Kind Regards,

 

Denzil

Denzil Peiris
Chetan_Tiwary_
Community Manager
Community Manager
  • 819 Views

@Denzil is /bin/mount  or /usr/bin/mount available there ?

Denzil
Mission Specialist
Mission Specialist
  • 799 Views

Hello Chetan_Tiwary_

 

Thank you for your help.

 

I am getting this >> root@denzil /]#, and from here how am to reach /bin/mount or /usr/bin/?

 

I Would appreciate your advise.

 

 

 

 

Kind Regards,

 

Denzil

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