Linux system cracked root password (modification of / etc/passwd file made it impossible to log in to the system)
1. When starting, press a key at random, space can be (cannot be Enter), let it stay in centos is about to enter the interface, move up and down,
2. Press e to enter the editing interface as follows. Change ro to "rw init=/sysroot/bin/sh". Then Ctrl+x starts
3. Enter the following commands in turn to modify the root password, and exit the forced restart after the modification is completed. chroot /sysroot/passwd touch / .autorelabel
4. exit & reboot → login with new password, problem solved
#
5. If you modify the root name (modify the/etc/passwd file, causing the administrator to be unable to log in (password error), You need to enter the bash interface from single user mode, enter/etc/passwd to modify the file back, modify the password and restart the same as above.
! [](https://s1.51cto.com/images/blog/201910/24/8d80e4831519d406929acfbd43549870.png? x-oss- process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
6, and then exit restart---exit && reboot → login with a new password, the problem solved