Enter single user mode under CentOS7
Centos7 uses grub2, which is different from centos6.x for single-user access. However, because it is not possible to use a real machine environment, it is just a rough description of the following ideas.
Init Method
1. The grub2 interface of centos7 has two entrances: normal system entrance and rescue mode;
2. Modify grub2 boot
Press "e" on the normal system portal to enter the edit mode. Search for the ro line starting with linux16;
Change ro to rw (Change read-only to writable)
Delete the rhgb quiet. (The quiet mode can be deleted if the code line does not exist)
Add init =/bin/sh; (or init =/bin/bash, specify the shell environment)
Press ctrl + x to start the system.
3. Modify the root password
# Passwd # change the password
# Touch/. autorelabel # It is said that selinux updated the label after restarting
# Exec/sbin/init # Start the init process normally
There is also a rd. break method (not tried)
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