Five years ago, Zhiju wrote about how to reset a forgotten password in Linux (centos). At that time, it was still a centos6. Yes, record it here so that you can find it easier next time you encounter it.
To be honest, I forgot to take screenshots at first, but the early startup is similar to centos6. You can refer to: https://www.vpsok.net/12719.html
First, restart the server, and then press esc key until the system selection interface appears, press e (this step is similar to centos6)
7_root
As shown in the picture above, two places are marked, among which the ro pointed by the first arrow Modify it to rw; the second time, add a space after LANG=en_US.UFT-8 at the end of the kernel: init=/sysroot/bin/sh
After these two modifications, press Ctrl+X to boot. In single-user mode, we then enter in sequence:
chroot  /sysroot
passwd root  #Enter the new password twice and press Enter
touch /.autorelabel
reboot
< x2>
After restarting, you can log in normally using the new password.

postid
23266

Leave a Reply