Forum

How to reset forgot...
 
Notifications
Clear all

How to reset forgotten root password in redhat Linux server

2 Posts
2 Users
0 Reactions
7,738 Views
Posts: 7
 mani
Topic starter
(@mani)
Active Member
Joined: 5 years ago

How to reset forgotten root password in redhat Linux server


1 Reply
Posts: 1
Admin
(@techlabzone)
New Member
Joined: 5 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: