1. (a) When the boot loader boot option menu is on, click the Keyboard button immediately and boot loader will pause.
(b) Press ' E ', Edit options menu
(c) Move up and down to the linux16 core command line
linux16/vmlinuz-3.10.0-123.el7.x86_64 root=uuid=449d53d1-84c2-40c0-b05e-d1900591d71b ro Rd.lvm.lv=vg_kvm7usb/swap Crashkernel=auto Vconsole.keymap=us crashkernel=auto vconsole.font=latarcyrheb-sun16th.lvm.lv=vg_kvm7usb/root rhgb quiet LANG=en_US. UTF-8 Rd.break |
(d) At the end of the core command line, add Rd.break .
(e) Press ctrl+x again to reboot with this setting.
After the power-on interactive command environment, is not the normal boot system, the normal boot system mounted in the/sysboo and mounted as read-only, must be re-attached to write, in order to modify the password, the steps are as follows:
(a) Re-mount the/sysroot as readable and writable.
switch_root:/# Mount–o Remount,rw/sysroot
(b) chroot working directory to/sysroot.
switch_root:/# Chroot/sysroot
(c) Set a new root password.
sh-4.2# passwd Root
(d) Because in this case, SELinux does not start, changes to all files may result in incorrect context of the document, to ensure that the SELinux context is reset
You have to add hidden files under the root directory. Autorelabel.
sh-4.2# Touch/.autorelabel
(e) Exit chroot
sh-4.2# Exit
switch_root:/#
(f) Exit the system and the system will automatically reboot.
switch_root:/# exit
After rebooting, log in with the modified root password.
Reference
Http://dywang.csie.cyut.edu.tw/moodle23/dywang/download/pdf/rhel7.pdf
Linux–redhat7/centos 7 forgot root password modification