Centos7/rhel7 reset the root password (rd. break and init methods), centos7rhel7
The single-user access mode and password reset mode for centos7/rhel7 have greatly changed. GRUB is changed from B-guided to ctrl + x-guided.
There are two methods to reset the password: rd. break and init.
Rd. break method:
1. at startup, on the startup interface, press "e" on the corresponding startup Item and kernel name ";
2. After Entering, find the place starting with linux16, press the "end" Key to the end, enter rd. break, and press ctrl + x to enter;
3. Enter the mount command and find that the root is/sysroot/and cannot be written. Only the ro = readonly permission is required;
4. mount-o remount, rw/sysroot/, re-mount, and then mount, and find that the r and w permissions are available;
5. Change the root of chroot/sysroot;
(1) echo redhat | passwd-stdin root: Change the root password to redhat, or enter passwd for interactive modification;
(2) cp and then modify the/etc/shadow file.
6. touch/. autorelabel takes effect for selinux.
7. Press ctrl + d to exit
8. Then reboot
So far, the password has been modified
Init method:
1. Start the system and press e to enter the editing mode when GRUB2 starts the screen display.
2. Add the following content at the end of the Parameter Line of linux16/linux/linuxefi: init =/bin/sh
3. Press Ctrl + x to start to shell.
4. mount the file system in writable mode: mount-o remount, rw/
5. Run passwd and change the root password as prompted.
6. If selinux is enabled in the system, you must run the following command. Otherwise, the system cannot be started properly: touch/. autorelabel.
7. Run the exec/sbin/init command to start the instance normally, or run the exec/sbin/reboot command to restart the instance.