November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Reset rhel7 root password

Reset rhel7 root password

 In the RHCSA examination they ask to reset the root password, In this article we are going to learn how to reset rhel7 root user password.
root_password_forgot
Whenever you type user password incorrectly it will shown an above error.
restart rhel7
Immediate After Right side of the corner there is a power button Click on that power button and Click on Restart Server. Server will restart.
Select Kernel
While restarting of server you have to press any key to stop the OS booting process yet the stage of Kernel. As shown in above screen shot kernel line will stop. Then Press ‘e’

After pressing key ‘e’ then kernel lines will be edited. As shown in below screenshot

rd.break console
if you see there is a line start with “linux16” go to that line press ‘END’ key to go last of the line. In END of the line write “rd.break console=tty1” (without quotations). Then Press CTRL+x
Server will go to Single user mode. As shown in above screen shot.
In this mode /sysroot file system bill be mounted as ReadOnly. We have to make /sysroot as ReadWrite then only we can able to change the password.

Changing password means we are indirectly writing the encrypted password in /etc/shadow file.

reset rhel7 root password
To mount /sysroot file system in ReadWrite run below command
# mount -o remount,rw /sysroot

Now change to root using below command
#chroot /sysroot

Now prompt will be changed to Shell.
# passwd
New Password: redhat
Retype Password: redhat

Now root password has been changed to ‘redhat’. If you reboot the server will not come back. in RHEL7 by default SELinux is in enforced mode we have to relabel the SELinux inorder to bring back the server in Normal Stage.

To Relabel the SELinux run below command
# touch /.autorelabel

autorelabel switch_root

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>