Skip to menu

RHCSA

root password reset in centos 8

John 2020.08.08 14:21 Views : 0

root password reset in centos 8

 

Step 1 : Select the Linux Kernel

Press up and down key simultaneously so that you will access the GNU-GRUB2 menu. From the first option hit E to edit the first grub menu.Select the Linux Kernel

Step 2 : Edit the Linux kernel Parameters

After editing the GNU-GRUB2 menu find the lines started with linux16 and hit End button to go to the last line and add  rd.break to it.
After add these lines hit Ctrl + X to boot.
Edit the Linux kernel Parameters

Step 3 : Recover the root password

First mount the /sysroot directory

# mount -o rw,remount /sysroot

Then Change the root directory to /sysroot

# chroot /sysroot

After that change the root password and you will be prompted to add the new password make sure it is strong.

# passwd root

Recover the root password

Step 4 : Auto Label the SELinux context to /etc/passwd file

Finally after running the passwd command the Linux need to be set the new password by relabeling to the /etc/passwd file and it is necessary for running with correct SELinux context.

# touch /.autorelabel

When done type two times exit and exit command to exit from chroot jail and to reboot the system.

# exit
# reboot

Auto Label the SELinux context to /etc/passwd file

It takes several minutes depending on your system CPU and Hard Drive speed.

Step 5 : You’ll then see login screen similar to below.

Login with root username and password provided during reset.

How To Reset Lost root Password in CentOS 8 / RHEL 8

No. Subject Author Date Views
» root password reset in centos 8 John 2020.08.08 0
Up