1.重启Linux系统主机并出现引导界面,如下图。
![781819553b0244a03dbaf63500660481.png](https://img-blog.csdnimg.cn/img_convert/781819553b0244a03dbaf63500660481.png)
2.按下键盘上的e键进入内核编辑界面。
![abd4b69aab37e4853764ebc102e05cac.png](https://img-blog.csdnimg.cn/img_convert/abd4b69aab37e4853764ebc102e05cac.png)
3.移动光标到红色找到LANG=zh_CN.UTF-8 增加“init=/sysroot/bin/sh” 修改后如下图。
![d4518b19e803efa1f110c2d6b6272df4.png](https://img-blog.csdnimg.cn/img_convert/d4518b19e803efa1f110c2d6b6272df4.png)
4.使用"ctrl+x"来重启服务器系统,重启后会进入到单用户模式。
![28aedb485336a4c3a9c8ec65af56623c.png](https://img-blog.csdnimg.cn/img_convert/28aedb485336a4c3a9c8ec65af56623c.png)
5.进行如下操作以修改root用户密码
#mount -o remount,rw /sysroot -->>重新挂载/sysroot目录,使具有r,w权限#chroot /sysroot -->>换根#passwd root#输入新的密码#touch /.autorelabel -->>selinux没有关闭,必须添加这一行#exit -->>退出#rebbot -->>重启,修改成功
exit之后如果reboot报错#Failed to start reboot.target:Transaction is destructive
这时候 reboot -f 就可以强迫重置开机了。