linux忘记密码怎么办?看我

1、重新启动,出现下面界面,按下ESC 或者 e在这里插入图片描述
2、在核心命令行最后加入 rd.break
在这里插入图片描述
3、再按下Ctrl+x ,重新以这个设定开机,以单用户模式启动,输入相关命令修改用户密码
3.1 、重新挂载/sysroot成可读可写,并切换到/sysroot

 switch_root:/# mount –o remount,rw /sysroot
 switch_root:/# chroot /sysroot

3.2、 设定密码

sh-4.2# passwd 用户名(要修改用户名就带上新的用户名,不修改不用写)
输入两次密码

4、因为在此情況下,SELinux 並沒有启动,对所有文件的更改,可能会造成文档的 context 不正确,为确保开机时重新设定 SELinux context,必須在根目录下添加隐藏文件.autorelabel。

 sh-4.2# touch /.autorelabel

5、退出chroot,并重新开机

 sh-4.2# exit
 switch_root:/# exit

简书参考文章:https://www.jianshu.com/p/33c86fe9b6f7

猜你喜欢

转载自blog.csdn.net/qq_42224683/article/details/112243607
今日推荐