Rhel7/centos7 used GRUB2 instead of the previous grub boot, initialized by Init and replaced with SYSTEMD initialization. The resulting root password is also different from the previous operation when it is retrieved. Specifically as follows:
1. Start the system, and when the GRUB2 start screen, press e key to enter edit mode
2. Add the following at the end of the parameter line at the kernel boot line
- Init=/bin/sh
3. Press Ctrl+x to boot to shell boot into single-user mode
4. Mount the root partition as read-write mode
Mount-o REMOUNT,RW/
At this point you can modify the password by passwd, but here are two points to note:
A, the host if have SELinux, need to create the Autorelabel file in the root partition, otherwise cannot start the system normally, the operation order is as follows:
Touch/.autorelabel
b, after the modification, as in the previous version of the implementation of the reboot command has been invalid, you need to enter the full path command, as follows
Exec/sbin/init or
Exec/sbin/reboot