修复模式:
1,特权模式:不需要root密码,直接以root账户身份登陆。
破解密码时特权模式。
破解root用户密码
1.重起系统,进入grub菜单
2.选择要使用的内核
3.按e
4.找到linux16那一行,把光标移动到最后,添加 init=/bin/sh或者添加rd.break console=tty0
5.ctrl+x #保存退出
6.进入系统后,以rw方式重新挂载/分区
#mount -o remount,rw / 或者 mount -o remount,rw /sysroot chroot /sysroot
7.永久关闭selinux
#vim /etc/sysconfig/selinux
8.修改密码
passwd
9. # touch /.autorelabel #重新识别新的root密码
10. # exec /sbin/init #重启机器,
防止破解root用户密码
在文件最后追加以下内容
vim /etc/grub.d/10_linux
cat <<EOF
set superusers="new"
password new 123456
EOF
生成新的grub文件
grub2-mkconfig --output=/boot/grub2/grub.cfg
验证
重启系统,按e进入,发现要进入单用户模式,需要用户名密码。
Comments NOTHING