Centos 7忘记用户登录密码的解决方法

一段时间没等我的centos了,突然记不起账号的登录密码了,网上搜了一些解决方法,尝试后,使用下面的方法解决了,

  1. 首先重启系统
    重启系统
  2. 在系统重启中进入到下面页面时按e进入编辑页面
  3. 在UTF-8的后面输入下面红框中的命令 ,注意要空格一下
    在这里插入图片描述
 4. 按下Ctrl+X启动
 5. 在swich_root:/#后输入mount -o remount,rw  /sysroot 
 6. 在swich_root:/#后输入chroot /sysroot 
 7. 在sh-4.2#后输入chroot /sysroot passwd 你的账号名
 8. 在sh-4.2#后输入你的新密码
 9. 在sh-4.2#后输入重复新密码
 10. 在sh-4.2#后输入touch ./autorelabel
 11. 在sh-4.2#后输入exit
 12. 在swich_root:/#后输入reboot

完成

发布了26 篇原创文章 · 获赞 1 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_42643690/article/details/103922075