Root password recovery on console of CentOS7

There are times you may need to reset the root password which is unknown to you.

This procedure will work fast on systems that have SELinux enabled and large volumes with lots of files which you definitely do not want to relabel as it is timeconsuming resulting in long down time.

you could remove rhgb quiet to get more info on the boot proces in case of trouble.

The system boots and presents you with a prompt: switch_root:/# _. We need to chroot to the filesystem on which the /etc/shadow file is present.

Now we need to continue the boot proces.

The boot process continues and you are presented by the regular login prompt.
However, we forced the system to boot in SELinux permissive mode because we needed to alter the shadow password file. We need to correct this:

Done.