Once you see the following screen, press "E" on your keyboard (for editing).
650) this.width=650; "src=" Http://s8.51cto.com/wyfs02/M01/5C/1D/wKioL1UbSkqQiWKMAABmNDHUsrw24.jpeg "alt=" How do I reset the forgotten root user account password in Centos/rhel 7? "/>
Press "E" to enter the edit boot menu
After you press the "E" on the keyboard, you will see a lot of text, which will be shortened according to the screen size.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/5C/1D/wKioL1UbSmGQ7VNQAAFgbgSQ_aE704.png "alt=" How do I reset the forgotten root user account password in Centos/rhel 7? "/>
Grub Configuration
Search for the text "RHGB quiet" and replace it with "init=/bin/bash" without quotation marks.
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/5C/22/wKiom1UbSTjScieXAAFiw1I24uo483.png "alt=" How do I reset the forgotten root user account password in Centos/rhel 7? "/>
Enable Shell
Once you have finished editing, press the "ctrl+x" key combination and it will start to boot with the specified parameters. You will get bash prompt.
650) this.width=650; "src=" Http://s6.51cto.com/wyfs02/M00/5C/22/wKiom1UbSUiDDYLUAAFGAbsIzQM36.jpeg "alt=" How do I reset the forgotten root user account password in Centos/rhel 7? "/>
Boot system
Now, run the following command on a single user mode to check the status of the root partition.
# Mount | grep root
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/5C/22/wKiom1UbSVeQy5rIAAJGh4Hxgkw875.png "alt=" How do I reset the forgotten root user account password in Centos/rhel 7? "/>
Check the root partition mount status
You may notice that the root partition is reported as "Ro" (read-only). We need to have read and write access to the root partition to change the root account password.
# Mount-o REMOUNT,RW/
Also check again and see if the root assignment is mounted in read-write permission mode.
# Mount | grep root
650) this.width=650; "src=" Http://s8.51cto.com/wyfs02/M02/5C/22/wKiom1UbSWiwfQKuAABqH3R_9I8335.png "alt=" How do I reset the forgotten root user account password in Centos/rhel 7? "/>
Set permissions on the root partition
Now you can change the root account password, just type the passwd command. But it's not over yet. We need to re-tag the selinux context. If we skip the step of re-tagging the entire selinux context, we can use the using password to log in.
# passwd root[Enter new password [re-enter new password]
# Touch/.autorelabel
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/5C/1D/wKioL1UbSrfymZbZAAH35uqdXk4121.png "alt=" How do I reset the forgotten root user account password in Centos/rhel 7? "/>
Reset Root account password
Reboot, log into the root account again and see if everything is OK?
# Exec/sbin/init
650) this.width=650; "src=" Http://s8.51cto.com/wyfs02/M01/5C/1D/wKioL1UbSsWxQzccAACxwkaaGOU890.png "alt=" How do I reset the forgotten root user account password in Centos/rhel 7? "/>
Cent OS Reset Root password