Linux-RedHat7/CentOS 7 forget the root password modification, redhat7centos
1. (a) when the grub boot loader boot option menu appears, click any keyboard restart and boot loader will be suspended.
(B) Press 'e' to edit the option menu.
(C) move upstream and downstream traffic to the Core Command Line of linux16
Linux/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-sun16 rd. lvm. lv = vg_kvm7usb/root rhgb quiet LANG = en_US.UTF-8 rd. break |
(D) add rd. break at the end of the core command line.
(E) Press Ctrl + x to start the instance again.
● The interactive command environment after startup is not the system for normal boot. The system is mounted to/sysboo and read-only, and must be remounted to writable, to modify the secret, follow these steps:
(A) remount/sysroot to readable and writable.
Switch_root:/# mount-o remount, rw/sysroot
(B) run the chroot working directory to/sysroot.
Switch_root:/# chroot/sysroot
(C) Set a new root password.
Sh-4.2 # passwd root
(D) in this case, SELinux is not started, and changes to all files may cause incorrect context in the Document. To ensure SELinux context is re-set during startup
You must add the hidden file. autorelabel in the root directory.
Sh-4.2 # touch/. autorelabel
(E) Quit chroot
Sh-4.2 # exit
Switch_root :/#
(F) Exit the system and the system automatically restarts.
Switch_root:/# exit
After restart, use the modified root password to log on.
Reference
Http://dywang.csie.cyut.edu.tw/moodle23/dywang/download/pdf/rhel7.pdf