Linux系统忘记root密码怎么办
Last updated
2023-01-18 17:56:52
{"value":"Linux \u7684\u5355\u7528\u6237\u6a21\u5f0f\u6709\u4e9b\u7c7b\u4f3c Windows \u7684\u5b89\u5168\u6a21\u5f0f\uff0c\u53ea\u542f\u52a8\u6700\u5c11\u7684\u7a0b\u5e8f\u7528\u4e8e\u7cfb\u7edf\u4fee\u590d\u3002\u5728\u5355\u7528\u6237\u6a21\u5f0f\uff08\u8fd0\u884c\u7ea7\u522b\u4e3a 1\uff09\u4e2d\uff0cLinux \u5f15\u5bfc\u8fdb\u5165\u6839 shell\uff0c\u7f51\u7edc\u88ab\u7981\u7528\uff0c\u53ea\u6709\u5c11\u6570\u8fdb\u7a0b\u8fd0\u884c\u3002\n\n\u5355\u7528\u6237\u6a21\u5f0f\u53ef\u4ee5\u7528\u6765\u4fee\u6539\u6587\u4ef6\u7cfb\u7edf\u635f\u574f\u3001\u8fd8\u539f\u914d\u7f6e\u6587\u4ef6\u3001\u79fb\u52a8\u7528\u6237\u6570\u636e\u7b49\u3002\n\n### \u5982\u4f55\u8fdb\u5165\u5355\u7528\u6237\u6a21\u5f0f\n\n\u5f53\u7136\u4e0d\u80fd\u76f4\u63a5\u6267\u884c\u547d\u4ee4 init 1\u4e86\uff0c\u56e0\u4e3a\u6211\u4eec\u7684\u5047\u8bbe\u662f\u7cfb\u7edf\u51fa\u73b0\u4e86\u95ee\u9898\uff0c\u5df2\u7ecf\u4e0d\u80fd\u6b63\u5e38\u767b\u5f55\u4e86\u3002\u90a3\u4e48\uff0c\u5982\u4f55\u8fdb\u5165\u5355\u7528\u6237\u6a21\u5f0f\u5462\uff1f\n\n\u9996\u5148\u9700\u8981\u91cd\u542f\u670d\u52a1\u5668\uff0c\u5728 GRUB \u8bfb\u79d2\u754c\u9762\u6309\u4efb\u610f\u952e\uff0c\u8fdb\u5165 GRUB \u83dc\u5355\u754c\u9762\uff0c\u5982\u56fe 1 \u6240\u793a\u3002\n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek11%2FLinux%E7%B3%BB%E7%BB%9F%E5%BF%98%E8%AE%B0root%E5%AF%86%E7%A0%81%E6%80%8E%E4%B9%88%E5%8A%9E%2F1.png)\n\n\u5728\u60f3\u8981\u8fdb\u5165\u5355\u7528\u6237\u6a21\u5f0f\u7684 Linux \u83dc\u5355\u4e0a\u6309\"e\"\u952e\uff0c\u5c31\u4f1a\u8fdb\u5165 GRUB \u7f16\u8f91\u754c\u9762\uff0c\u5982\u56fe 2 \u6240\u793a\u3002\n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek11%2FLinux%E7%B3%BB%E7%BB%9F%E5%BF%98%E8%AE%B0root%E5%AF%86%E7%A0%81%E6%80%8E%E4%B9%88%E5%8A%9E%2F2.png)\n\n\u56fe 2 GRUB\u7f16\u8f91\u754c\u9762\n\n\u5728 GRUB \u7f16\u8f91\u754c\u9762\u4e2d\uff0c\u79fb\u52a8\u5149\u6807\u5230\u7b2c\u4e8c\u884c kernel \u884c\uff0c\u7136\u540e\u7ee7\u7eed\u6309\"e\"\u952e\uff0c\u8fdb\u5165\u884c\u7f16\u8f91\u754c\u9762\u3002\u5728\u6b64\u884c\u6700\u540e\u8f93\u5165\"\u7a7a\u683c single\"\uff0c\u4ee3\u8868\u542f\u52a8\u8fdb\u5165\u5355\u7528\u6237\u6a21\u5f0f\uff08\u6ce8\u610f\uff1a\u7a7a\u683c\u5fc5\u987b\u5b58\u5728\uff09\uff0c\u5982\u56fe 3 \u6240\u793a\u3002\n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek11%2FLinux%E7%B3%BB%E7%BB%9F%E5%BF%98%E8%AE%B0root%E5%AF%86%E7%A0%81%E6%80%8E%E4%B9%88%E5%8A%9E%2F3.png)\n\n\u56fe 3 GRUB\u884c\u7f16\u8f91\u754c\u9762\n\n\u7136\u540e\u6309\u56de\u8f66\u952e\uff0c\u5c31\u4f1a\u56de\u5230\u4e0a\u4e00\u4e2a\u754c\u9762\uff0c\u5982\u56fe 2 \u6240\u793a\u3002\u518d\u6309\"b\"\u952e\uff08\u542f\u52a8\uff09\uff0c\u5c31\u4f1a\u542f\u52a8\u8fdb\u5165\u5355\u7528\u6237\u6a21\u5f0f\u3002\u5355\u7528\u6237\u6a21\u5f0f\u662f\u4e0d\u9700\u8981\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801\u5c31\u80fd\u76f4\u63a5\u8fdb\u5165\u63d0\u793a\u7b26\u754c\u9762\u7684\uff0c\u5982\u56fe 4 \u6240\u793a\u3002\n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek11%2FLinux%E7%B3%BB%E7%BB%9F%E5%BF%98%E8%AE%B0root%E5%AF%86%E7%A0%81%E6%80%8E%E4%B9%88%E5%8A%9E%2F4.png)\n\n\u56fe 4 \u5355\u7528\u6237\u6a21\u5f0f\u63d0\u793a\u7b26\u754c\u9762\n\n\u6211\u4eec\u5df2\u7ecf\u767b\u5f55\u4e86 Linux \u7cfb\u7edf\u7684\u5355\u7528\u6237\u6a21\u5f0f\uff0c\u800c\u4e14\u662f\u4e0d\u9700\u8981\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801\u5c31\u53ef\u4ee5\u76f4\u63a5\u8fdb\u5165\u7684\u3002\u8fd9\u65f6\u5982\u679c\u6709\u7cfb\u7edf\u95ee\u9898\uff0c\u5c31\u53ef\u4ee5\u5728\u5355\u7528\u6237\u6a21\u5f0f\u4e2d\u8fdb\u884c\u4fee\u590d\u4e86\u3002\n\n### \u5355\u7528\u6237\u6a21\u5f0f\u5e38\u89c1\u7684\u9519\u8bef\u4fee\u590d\n\n\u6211\u4eec\u5df2\u7ecf\u8fdb\u5165\u4e86\u5355\u7528\u6237\u6a21\u5f0f\uff0c\u90a3\u4e48\u6211\u4eec\u5728\u5355\u7528\u6237\u6a21\u5f0f\u4e2d\u4e3b\u8981\u53ef\u4ee5\u4fee\u590d\u54ea\u4e9b\u7cfb\u7edf\u9519\u8bef\u5462\uff1f\u4e0b\u9762\u4e3e\u51e0\u4e2a\u4f8b\u5b50\u3002\n\n#### \u9057\u5fd8root\u5bc6\u7801\n\n\u8fd9\u662f\u7ba1\u7406\u5458\u6700\u5bb9\u6613\u72af\u7684\u9519\u8bef\uff0c\u5e94\u8be5\u5982\u4f55\u4fee\u590d\u5462\uff1f\u5f53\u7136\u662f\u4f7f\u7528\u5355\u7528\u6237\u6a21\u5f0f\u8fdb\u884c\u4fee\u590d\u4e86\uff0c\u56e0\u4e3a\u8fdb\u5165\u5355\u7528\u6237\u6a21\u5f0f\u7684\u6700\u5927\u7279\u70b9\u5c31\u662f\u4e0d\u9700\u8981\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002\u65e2\u7136\u5df2\u7ecf\u767b\u5f55\u4e86\u5355\u7528\u6237\u6a21\u5f0f\uff0c\u90a3\u4e48\u76f4\u63a5\u7ed9 root \u7528\u6237\u8bbe\u5b9a\u65b0\u5bc6\u7801\u5373\u53ef\u3002 \u547d\u4ee4\u5982\u4e0b\uff1a\n\n``` \n[root@localhost \/\\]# passwd root\n```\n#### \u4fee\u6539\u7cfb\u7edf\u9ed8\u8ba4\u8fd0\u884c\u7ea7\u522b\n\n\u5982\u679c\u6211\u4eec\u628a\u7cfb\u7edf\u7684\u9ed8\u8ba4\u8fd0\u884c\u7ea7\u522b\u4fee\u6539\u9519\u8bef\uff0c\u6bd4\u5982\u6539\u4e3a\u4e86 0 \u6216 6\uff0c\u7cfb\u7edf\u5c31\u4e0d\u80fd\u6b63\u5e38\u542f\u52a8\u4e86\u3002\u8fd9\u65f6\u4e5f\u53ef\u4ee5\u5229\u7528\u5355\u7528\u6237\u6a21\u5f0f\u8fdb\u884c\u4fee\u590d\uff0c\u53ea\u9700\u76f4\u63a5\u4fee\u6539\u9ed8\u8ba4\u8fd0\u884c\u7ea7\u522b\u914d\u7f6e\u6587\u4ef6 \/etc\/inittab\uff0c\u628a\u7cfb\u7edf\u9ed8\u8ba4\u8fd0\u884c\u7ea7\u522b\u4fee\u6539\u56de\u6765\u5373\u53ef\u3002\u547d\u4ee4\u5982\u4e0b\uff1a\n\n```\n[root@localhost \/\\]# vi \/etc\/inittab\nid:3:initdefault:\n```\n\n\\\\#\u628a\u9ed8\u8ba4\u8fd0\u884c\u7ea7\u522b\u4fee\u6539\u4e3a3\u62165\u3002\u6ce8\u610f\uff1a\u7cfb\u7edf\u7684\u9ed8\u8ba4\u8fd0\u884c\u7ea7\u522b\u53ea\u80fd\u4f7f\u75283\u62165\n\n\u7406\u8bba\u4e0a\uff0c\u53ea\u8981\u80fd\u591f\u8fdb\u5165\u5355\u7528\u6237\u6a21\u5f0f\uff0c\u90a3\u4e48\u7cfb\u7edf\u9519\u8bef\u5c31\u53ef\u4ee5\u5728\u5355\u7528\u6237\u6a21\u5f0f\u4e2d\u8fdb\u884c\u4fee\u590d\u3002\u5f53\u7136\uff0c\u5224\u65ad\u7cfb\u7edf\u5230\u5e95\u54ea\u91cc\u51fa\u73b0\u4e86\u95ee\u9898\uff0c\u662f\u9700\u8981\u5927\u91cf\u7684\u7ecf\u9a8c\u79ef\u7d2f\u7684\u3002\n"}