Linux 忘记密码解决方法
很多朋友经常会忘记 Linux 系统的 root 密码,linux 系统忘记 root 密码的情况该怎么办呢?重新安装系统吗?当然不用!进入单用户模式更改一下 root 密码即可。
步骤如下:
重启 linux 系统

3 秒之内要按一下回车,出现如下界面

然后输入 e

在第二行最后边输入 single,有一个空格。具体方法为按向下尖头移动到第二行,按"e"进入编辑模式

在后边加上 single 回车

最后按"b"启动,启动后就进入了单用户模式了

此时已经进入到单用户模式了,你可以更改 root 密码了。更密码的命令为 passwd

【使用系统安装光盘的救援模式】
救援模式即 rescue ,这个模式主要是应用于,系统无法进入的情况。如,grub 损坏或者某一个配置文件修改出错。如何使用 rescue 模式呢?
光盘启动,按 F5 进入 rescue 模式

输入 linux rescue 回车

选择语言,笔者建议你选择英语

选择 us 键盘


这里问你是否启动网络,有时候可能会联网调试。我们选 no

这里告诉我们,接下来会把系统挂载在/mnt/sysimage 中。
其中有三个选项:
这里我们选择 Continue。

至此,系统已经挂载到了/mnt/sysimage 中。接下来回车,输入 chroot /mnt/sysimage 进入管理员环境。

提示: 其实也可以到 rescue 模式下更改 root 的密码的。这个 rescue 模式和 windows PE 系统很相近。
当运行了 chroot /mnt/sysimage/ 后,再 ls 看到目录结构和原来系统中的目录结构是一样的。
没错!现在的环境和原来系统的环境是一模一样的。你可以输入 exit 或者按 Ctrl + D 退出这个环境。然后你再 ls 看一下

这个目录其实就是 rescue 模式下的目录结构,而我们的系统文件全部在 /mnt/sysimage 目录下。
版权声明: 本文为 InfoQ 作者【向阳逐梦】的原创文章。
原文链接:【http://xie.infoq.cn/article/447b833304b0ca03dd214f37f】。文章转载请联系作者。
评论