How To Reset Root Password In CentOS 7
There is a tool that’s useful for situations that require a superuser access without the password, cause this program changes the apparent root directory for the current running process and its children. If you want to know more about it, please visit the Wikipedia article for chroot.
Before explaining the process, I’ve to tell you something important: This process is for CentOS 7 and it’s different to previous releases because it is the most recent version and its SELinux integration is better. So if you have a previous release installed on your computer please visit the documentation at CentOS wiki.
The first step to reset the root password is boot the CentOS machine in emergency mode, and for this process, we’ll use rd.break.
Start the system and, on the GRUB 2 boot screen, press the ‘e’ key for edit:
The way to set a password is easy just type passwd user_name
user_name isn’t necessary if you’re logged in the session, so for this tutorial, you must type only “passwd”