Forum

How to reset forgot...
 
Notifications
Clear all

How to reset forgotten root password in redhat Linux server


mani
Posts: 7
 mani
Topic starter
(@mani)
Active Member
Joined: 4 years ago

How to reset forgotten root password in redhat Linux server

1 Reply
Admin
Posts: 1
Admin
(@techlabzone)
Member
Joined: 4 years ago

First, reboot or power on your Redhat 8/CentOS 8 system. Select the kernel you want to boot into. Next, press ‘e’ on the keyboard to interrupt the boot process and make changes.

Locate the ro (read-only) kernel parameter as highlighted below.

Replace the kernel parameter ro with rw and append an extra kernel parameter init=/sysroot/bin/sh. In a nutshell, simply replace the kernel parameter ro with rw init=/sysroot/bin/sh.

Once done with making the changes, hit Ctrl + X combination on the keyboard to enter single-user mode.

Next, run the command below to mount the root file system in read and write mode.

:/# chroot /sysroot

You can now change the root password by executing the command:

:/# passwd root

Next, run the command below to enable SELinux relabelling. (If selinux is in enforce mode)

:/# touch /.autorelabel

To apply the changes, exit and reboot the Redhat 8/CentOS 8 system.

:/# exit
:/# reboot

Please refer here for screenshots.
https://it.techlabzone.com/how-to-reset-forgotten-root-password-in-redhat-8-centos-8/operating-system/

Reply

Leave a reply

Author Name

Author Email

Title *

Preview 0 Revisions Saved
Share: