centos系统忘记密码,重置密码

1、重启系统,在开机过程中,出现以下界面时按e键,进入编辑界面。

 

按e键之后进入如下界面:

2、按方向键下键↓,找到LANG=en_US.UTF-8,在后面追加rw single init=/bin/bash,然后按ctrl+x重启系统

 3、进入bash界面后,可以输入passwd命令重新设置root密码

4.提示密码过于简单问题

BAD PASSWORD: The password fails the dictionary check - it is based on a dictionary word
vim /etc/pam.d/system-auth
#注释掉以下行
#password    requisite     pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type=


#删除掉下行中的选项use_authok
password    sufficient    pam_unix.so sha512 shadow nullok try_first_pass #use_authtok

 

4、如果开启了SELinux,执行命令touch /.autorelabel命令

5、输入exec /sbin/init命令重启系统

6、使用新设置的密码进入系统之后,为了安全起见,可以输入reboot重新启动一次系统。

 

 

 

posted @ 2023-12-06 15:06  小代小代  阅读(494)  评论(0)    收藏  举报