Cross-platform series summary: http://www.cnblogs.com/dunitian/p/4822808.html#linux
**Press e ** when booting up (If you are using it, you can enter reboot, and then quickly press Enter to enter this page)
Just press the down arrow all the way (we want to add something at the bottom)
Find Linux16, **Add init=/bin/sh ** at the end (to linux16, press the end key to reach the end, remember to add a space), and then press ctrl+X to enter **single user Mode ** (a bit like SQLServer restored)
**mount -o remount,rw / **Mount the root directory as readable and writable mode
passwd Reset the Root password, enter the password, and then confirm the password (I don’t know why, is it true for Centos now, remember that it was prompted in English before)
**touch /.autorelabel **Create the system file .autorelabel. I mentioned this command before touch. You can see this for basic commands (click me) http://dnt.dkill.net/dnt/linux/cmd.html
exec /sbin/init initialize and start the system
Enter the password just now and find ~ok
Expansion description, the Internet says that CentOS7 can no longer be restored in this traditional way,,,, uh, I seem to be able to, maybe some can’t, post other methods on the Internet:
CentOS 7&RHEL 7 enters the single-user mode and reset password mode has undergone major changes. GRUB has been booted from b to ctrl+x.
There are two main ways to reset the password: rd.break and init.
rd.break method:
1、 When booting, press "e" on the boot interface, the corresponding boot item, and the kernel name;
2、 After entering, find the beginning of linux16, press "end" to the end, enter rd.break, and press ctrl+x to enter;
3、 After entering, enter the command mount and find that the root is /sysroot/, and cannot write, only ro=readonly permission;
4、 mount -o remount,rw /sysroot/, re-mount, then mount, find r,w permissions;
5、 chroot /sysroot/ change the root;
(1) echo RedHat|passwd -stdin root Change the root password to redhat, or enter passwd to change it interactively;
(2) There is a cp first, and then modify the /etc/shadow file
6、 touch /.autorelabel This sentence is for selinux to take effect
7、 ctrl+d to exit
8、 Then reboot
At this point, the password modification is complete
init method:
Recommended Posts