If you forgot your CentOS 7 root password the first thing that might cross your mind would be to boot in single user mode and reset the root password from there. That was working just fine in CentOS 5.x or CentOS 6.x but in 7.0 the things are a little bit different.

It is still possible though.

You will have to follow these steps:

1) Start the system and on the GRUB 2 boot menu press e key for edit.
2) Search for the line containing linux16 and at the end of it add: rd.break enforcing=0
3) Press Ctrl+X to boot the system with the modified parameters
4) The system will boot but the file system is mounted as read-only in /sysroot
5) We have to remount the file system as writable:

6) Change the file system’s root as follows:

7) Change the password using passwd command:

8) If you have SELINUX enabled you have to relabel all the files on the next system boot (if you have SELINUX disabled you can just ignore this step):

9) Remount the file system as read-only

10) exit from the chroot environment by simply typing: exit
11) Reboot

On the next system boot, you will be able to login with the new root password.


About Author

I am a linux passionate and currently working as a Linux Senior System Administrator. I also am a freelancer and help people to complete different jobs. You can hire me on Freelancer.com