7 Easy Steps To Recover Root Password On CentOS/RHEL (5 and 6)
Using CentOS 6 VM on VMware:
After selecting press "e" again which will take you to new window select the kernel you want to edit and press "e" to edit the kernel.
After that you get the screen same as above in the screenshot, mention the runlevel you want to boot your system, by default it is set to runlevel 5 that is GUI mode we need to boot in single user mode so give one space and press 1 and hit Enter.
1. Start your VM, and boot the system.
System boots up and we get the login panel, and it shows the password is incorrect.
Since there is no way in to my system, so lets reboot the system and edit the boot loader (Grub) restart right click on the machine tab, Power >> Restart Guest
2. Press 'e' to edit the boot loader before booting.
Select CentOS Version
After selecting press "e" again which will take you to new window select the kernel you want to edit and press "e" to edit the kernel.
After that you get the screen same as above in the screenshot, mention the runlevel you want to boot your system, by default it is set to runlevel 5 that is GUI mode we need to boot in single user mode so give one space and press 1 and hit Enter.
3. Type '1' at the end of the line to select single user mode and hit enter
4. Highlight the list item with kernel 'vmlinuz' in it by using the arrow keys and press 'b' to boot the system with the new argument.
5. The system will boot into single user mode and you will see bash prompt, now change the password.
eg: passwd
And if we don't mention any parameter to passwd command it will be changing password for the root user
6. Type 'init 5' to run the system with Full Multiuser with Networking (GUI) mode.
After this you will be able to login to the machine with new password
Note: In this article i have changed the root password you can change the password of any user as mentioned in step 5 , This document works well for centos/rhel 5 and 6
Note: In this article i have changed the root password you can change the password of any user as mentioned in step 5 , This document works well for centos/rhel 5 and 6