We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – Reset root password in RHEL 8 / CentOS 8 / Rocky Linux 8

Learn how to – Reset root password in RHEL 8 / CentOS 8 / Rocky Linux 8.

As humans, we tend to forget things especially if all is stored in our minds. Is it possible to reset a forgotten root password on RHEL 8 / CentOS 8 / Rocky Linux 8 Linux?. If this is your question, then the answer is YES. It is easy to reset your root password if you have an active user account with sudo privileges. All you need to do is run:

sudo passwd root

This will ask you for the new root password and confirmation. But what if you don’t have access to a local user with sudo privileges and can’t recover root password via other means. This leaves you with the manual password recovery on your RHEL 8 server from the Grub boot menu.

Step 1: Boot / reboot RHEL 8 / CentOS 8 / Rocky Linux 8

The first step is bringing up RHEL 8 / CentOS 8 Linux system in the stopped state or rebooting a running RHEL / CentOS 8 system.

Step 2: Interrupt Boot process and reset root password

Once you see the grub menu, press the “e” key in your keyboard to interrupt the boot process.

Press e as shown in the screenshot

This will show you the Kernel boot parameters. We will modify these options so as to reset the root password on RHEL 8. The default parameters configured looks like below.

remove ro crash from the line.

Under the linux line, Press <ctrl+e> to go to the end of line and delete “ro crash“, then add “rd.break” to look like below.

When done, press <Ctrl-x> to start system.

This will take you to a shell where you have to remount root of the system with rw flag since it is in read only mode.

mount -o remount,rw /sysroot

Switch to /sysroot directory and reset root password.

chroot /sysroot

Reset root password on RHEL 8 using the passwd command.

passwd

Enter desired password and confirm when prompted. Once password is set, enable SELinux relabeling on reboot and exit the console.

touch /.autorelabel
exit
exit

Screenshot below should help you visualize all reset actions.

The system will resume normal reboot and check SELinux policy against all system files and directories.

You’ll then see login screen similar to below. Login with root username and password provided during reset.

And boom!. You have successfully performed password reset of root user on RHEL 8 / CentOS 8. Well done.

  • Reset root password on RHEL 8
  • Reset root password on CentOS 8
  • Reset root password on Rocky Linux 8
  • Recover root password on CentOS 8
  • Recover root password on Rocky Linux 8

Video Courses to Learn Linux System Administration:

16
620.203,10