1、系统开机,使用 ↑ 和 ↓ 将选择行设置为第一行(背景高亮即为选中)
2、按下键盘上的 e,进入编辑模式
3、将光标一直移动到 LANG=en_US.UTF-8 后面,空格,再追加 init=/bin/sh
4、按下CTRL+X 进行引导启动,成功后进入该界面
sh-4.2#
5、重新挂载已经挂载了的文件系统(以读写权限挂载)
mount -o remount, rw /
6、修改密码
passwd root
7、如果报 "BAD PASSWORD: The password fails the dictionary check - it is based on a dictionary word" 错误
解决方法:
cp /etc/pam.d/system-auth /etc/pam.d/system-auth.bak
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
8、重启
exec /sbin/init