Single User Mode: Resetting/Recovering Forgotten Root User A ccount Password in RHEL/CentOS 7
Single User Mode: Resetting/Recovering Forgotten Root User Account Password in RHEL7/CentOS7
- boot into single user mode. To do this reboot the Server, as soon as you get the flash screen as below.
- Press ‘e’ (stands for edit) from keyboard.
After you press 'e' from keyboard you would see a lot of text which may be clipped as per the size of your screen.
- Search for the text “rhgb quiet”
- Replace “rhgb quiet” with “init=/bin/bash” without quotes.
- Once done editing press 'ctrl+x' and it will start booting with specified parameter. And you will get bash prompt.
- Now check the status of root partition by running following command on the single user mode.
# mount | grep root
- You may notice that root partition is reported to be 'ro' (Read Only). We need to have read-write permission on root partition to change the root password.
# mount -o remount,rw /
- Also cross check, if the root partition is mounted with read-write permission mode.
# mount | grep root
- Now you can change the root password by typing the passwd command. But that is not done. We need to relabel SELinux context. If we skip relabeling the whole SELinux context we would be able to login using using password.
# passwd root
[Enter New Password]
[Re-enter New Password]
# touch /.autorelabel
- Run below command to reboot and login again to root account and see if everything works ok or not?
# exec /sbin/init
Reboot the server and login with new password
Comments
Post a Comment