How to Reset the Forgotten Root Password of Rhel7/CentOS7

reset root password rhel 7, How to reset the root password on RHEL7, Reset Root Password in RHEL 7, Reset Forgotten Root Password, reset root password centos 7

How to Reset the Forgotten Root Password of Rhel7/CentOS7
This post shows you how to reset the root password of RHEL7/CentOS7 systems with screenshots. As a Linux admin, we may come in a situation to reset the forgetten root password on RHEL7/CentOS7 systems.

Steps involved to recover/reset the root password:
1. Boot the Server to reset the root password.
2. Edit the Grub2 boot menu.
3. Remount the / partition to read/write mode.
4. Reset the root password.
5. Relabel the SELinux
6. Reboot the server and login with the new root password.

1. Boot the Server to reset the root password.
Boot the Server and interrupt the grub2 boot menu. Once you interrupted, your screen will be similar to the image below.
reset root password rhel7
2. Edit the Grub2 boot menu.
Press "e" to edit the default boot OS, normally it would be the first line. Once you pressed "e", find the words "rhgb quiet" in the vmlinuz kernel line as shown in the below image.
Resetting the Root Password of RHEL7
Replace the words "rhgb quiet" with "init=/bin/bash" and press "Ctrl + x" as shown in the below image. This will take us to the single user mode which allow us to perform the maintenance activity.
How to reset the root password on RHEL 7
3. Remount the / partition to read/write mode.
[ads-post]
By default root partition will be mounted as read-only in single user mode. If we want to reset the password, the passwd changes should be affected in /etc/passwd file. So it should be writable to do the passwd changes. So we make the / partition to read/write mode.
bash-4.2# mount -o remount,rw /
Reset Forgotten Root Password
4. Reset the root password.
Lets reset the password of root with your new password using the below command, which will prompt to enter the new password for two times as shown in the above image.
bash-4.2# passwd root
5. Relabel the SELinux
This is a  steps mandatory to ensure that the SELinux context for entire system is relabeled after reboot, If you ignore this step, you will not be able to login with your new root password.
bash-4.2# touch /.autorelabel
6. Reboot the server and login with the new root password.
Once you reset the root password, reboot the server using the below and login with your new password.
bash-4.2# exec /sbin/init
Once the server is rebooted, you can login with your new root password successfully.

Thanks for reading our post. share with your friends. We appreciate your feedback, Leave your comments if any.
We have more articles to be updated soon. To not miss any updates, Follow us on social networking sites and Subscribe us on our Youtube channel.

Keywords : reset root password rhel 7, Resetting the Root Password of RHEL7, How to Reset the Forgotten Root Password of Rhel7/CentOS7, Recover a forgotten root password on rhel7, How to reset the root password on RHEL7, Reset Root Password in RHEL 7, Reset forgotten RHEL 7 CentOS 7 root password, Reset Forgotten Root Password, reset root password centos 7
June 12, 2016

Post a Comment

[disqus][facebook][blogger]

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget