1)首先开机按E进入GRUB菜单
2)找到linux16关键字开头的行,在末尾添加rd.break console=tty0 ctrl+x保存并退出
3)进入单用户模式
switch_root:/# mount -o remount,rw /sysroot //重新挂载root目录
switch_root:/# chroot /sysroot //切换到sysroot目录
sh-4.2#passwd root //重设root口令
sh-4.2#touch ./autorelabel //添加修改生效文件,通知selinux
sh-4.2#exit //推出
switch_root:/#reboot //重启