VMware虚拟机CentOS 7忘记登陆密码问题的解决方案
<div id="navCategory"><h5 class="catalogue">目录</h5><ul class="first_class_ul"><li>CentOS 7忘记登陆密码</li><li>VMware虚拟机修改密码</li></ul></div><p class="maodian"></p><h2>CentOS 7忘记登陆密码</h2><p>1. 重启虚拟机,在重启时不停按E键进入初始化脚本编辑界面</p>
<p style="text-align:center"><img style="max-width:100%!important;height:auto!important;"alt="" height="448" src="https://zhuji.jb51.net/uploads/allimg/20250608/2-25060Q63454L8.png" width="628" /></p>
<p style="text-align:center"><img style="max-width:100%!important;height:auto!important;"alt="" height="344" src="https://zhuji.jb51.net/uploads/allimg/20250608/2-25060Q63454Y5.png" width="626" /></p>
<p>2.在初始化脚本编辑界面,按↓键向下拉到最后,找到LANG=/zh_CN.UTF-8那里,输入空格,接着添加 "<strong>init=/bin/sh</strong>" 。然后按<strong>ctrl+X</strong>键进入下一步。</p>
<p style="text-align:center"><img style="max-width:100%!important;height:auto!important;"alt="" height="345" src="https://zhuji.jb51.net/uploads/allimg/20250608/2-25060Q63455R2.png" width="620" /></p>
<p>3. 在界面中逐步输入下面命令:</p>
<div class="dxycode"><pre class="brush:bash;"># 重新挂载文件系统路径/,并将其设置为可读写模式
mount -o remount,rw /
# 设置登录账户和密码,格式:passwd+登录账户,随后输入两遍新密码
passwd root
# 为让SELinux(安全子系统)生效,创建一个隐藏文件.autorelabel,该文件通知SELinux允许修改密码
touch /.autorelabel
# 重新启动虚拟机
exec /sbin/init</pre></div>
<p>具体操作如下图:</p>
<p style="text-align:center"><img style="max-width:100%!important;height:auto!important;"alt="" height="176" src="https://zhuji.jb51.net/uploads/allimg/20250608/2-25060Q63455C9.png" width="770" /></p>
<p>4.重启后,输入设置的新密码即可正常登陆进入虚拟机。</p>
<p class="maodian"></p><h2>VMware虚拟机修改密码</h2>
<p>打开一台创建许久的虚拟机准备使用的时,发现自己的密码忘记了,这个时候我们可以执行重置密码的操作</p>
<p style="text-align:center"><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250608/2-25060Q63635L0.png" /></p>
<p>1.重启虚拟机</p>
<p style="text-align:center"><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250608/2-25060Q6363D44.png" /></p>
<p>2.弹出下图界面之后按 “e” 键</p>
<p style="text-align:center"><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250608/2-25060Q6363DU.png" /></p>
<p>3.初始化脚本编辑界面</p>
<p style="text-align:center"><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250608/2-25060Q6363KB.png" /></p>
<p>4.使用上下箭头划到下面,在UTF-8后面输入 console=tty0 rd.break ,按 ctrl+x 退出5.进入到系统紧急救援模式,</p>
<p>输入</p>
<p>mount -o remount,rw /sysroot/</p>
<p>chroot /sysroot/</p>
<p style="text-align:center"><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250608/2-25060Q6363O18.png" /></p>
<p>5.输入passwd 用户名,输入两次密码(不会显示输入的密码)</p>
<p style="text-align:center"><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250608/2-25060Q6363UN.png" /></p>
<p>6.黑色小方块是中文乱码,不用管</p>
<p style="text-align:center"><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250608/2-25060Q6363W17.png" /></p>
<p>7.退出exit,退出两次等待重启即可</p>
<p style="text-align:center"><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250608/2-25060Q6363T01.png" /></p>
<p>8.重启之后输入自己设置的新密码就可以登录进去了</p>
<p style="text-align:center"><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250608/2-25060Q6363b42.png" /></p>
<p>到这里修改密码的流程就全部完成了。</p>
<p>以上就是解决VMware虚拟机CentOS 7 忘记登陆密码问题的详细内容,更多相关资料请阅读琼殿技术社区其它文章!</p>
頁:
[1]