{"id":63467,"date":"2025-04-29T10:58:54","date_gmt":"2025-04-29T02:58:54","guid":{"rendered":"https:\/\/fwq.ai\/blog\/63467\/"},"modified":"2025-04-29T10:58:54","modified_gmt":"2025-04-29T02:58:54","slug":"centos7%e6%80%8e%e4%b9%88%e8%8e%b7%e5%8f%96root%e6%9d%83%e9%99%90-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/63467\/","title":{"rendered":"centos7\u600e\u4e48\u83b7\u53d6root\u6743\u9650"},"content":{"rendered":"<blockquote><p>\n  \u6709\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\u53ef\u83b7\u53d6 centos 7 \u4e2d\u7684 root \u6743\u9650\uff1a 1. \u4f7f\u7528 &#8220;su&#8221; \u8fd0\u884c\u547d\u4ee4\u3002 2. \u4f7f\u7528 &#8220;sudo&#8221; \u8fd0\u884c\u5355\u4e2a\u547d\u4ee4\u3002 3. \u542f\u7528 root \u7528\u6237\u5e76\u8bbe\u7f6e\u5bc6\u7801\u3002\u6ce8\u610f\uff1a\u4f7f\u7528 root \u6743\u9650\u65f6\u8981\u8c28\u614e\uff0c\u56e0\u4e3a\u5b83\u4eec\u53ef\u80fd\u4f1a\u635f\u574f\u7cfb\u7edf\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202404\/07\/2024040719572186153.jpg\" class=\"aligncenter\" title=\"centos7\u600e\u4e48\u83b7\u53d6root\u6743\u9650\u63d2\u56fe\" alt=\"centos7\u600e\u4e48\u83b7\u53d6root\u6743\u9650\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 CentOS 7 \u4e2d\u83b7\u53d6 root \u6743\u9650<\/strong><\/p>\n<p>\u8981\u83b7\u53d6 CentOS 7 \u4e2d\u7684 root \u6743\u9650\uff0c\u6709\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a<\/p>\n<p><strong>1. \u4f7f\u7528\u201csu\u201d<\/strong><\/p>\n<p>\u201csu\u201d\u547d\u4ee4\u5141\u8bb8\u7528\u6237\u5728\u63d0\u5347\u7279\u6743\u7684\u60c5\u51b5\u4e0b\u8fd0\u884c\u547d\u4ee4\u3002\u8981\u4f7f\u7528\u5b83\uff0c\u8bf7\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>su<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7cfb\u7edf\u5c06\u63d0\u793a\u60a8\u8f93\u5165 root \u5bc6\u7801\u3002\u8f93\u5165\u5bc6\u7801\u540e\uff0c\u60a8\u5c06\u83b7\u5f97 root \u6743\u9650\u3002<\/p>\n<p><strong>2. \u4f7f\u7528 sudo<\/strong><\/p>\n<p>\u201csudo\u201d\u547d\u4ee4\u5141\u8bb8\u7528\u6237\u4ee5 root \u6743\u9650\u8fd0\u884c\u5355\u4e2a\u547d\u4ee4\u3002\u8981\u4f7f\u7528\u5b83\uff0c\u8bf7\u5728\u547d\u4ee4\u524d\u8f93\u5165\u201csudo\u201d\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>sudo &lt;command&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7cfb\u7edf\u5c06\u63d0\u793a\u60a8\u8f93\u5165\u60a8\u7684\u7528\u6237\u5bc6\u7801\u3002\u8f93\u5165\u5bc6\u7801\u540e\uff0c\u60a8\u53ef\u4ee5\u8fd0\u884c\u8be5\u547d\u4ee4\u3002<\/p>\n<p><strong>3. \u542f\u7528 root \u7528\u6237<\/strong><\/p>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cCentOS 7 \u4e2d\u7684 root \u7528\u6237\u88ab\u7981\u7528\u3002\u8981\u542f\u7528\u5b83\uff0c\u8bf7\u6309\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a<\/p>\n<ul>\n<li>\u4f7f\u7528\u201csu\u201d\u6216\u201csudo\u201d\u547d\u4ee4\u5207\u6362\u5230 root \u7528\u6237\u3002<\/li>\n<li>\u7f16\u8f91 \/etc\/passwd \u6587\u4ef6\uff1a<\/li>\n<\/ul>\n<pre>nano \/etc\/passwd<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u627e\u5230\u5e26\u6709\u201croot\u201d\u884c\u7684\u5185\u5bb9\uff0c\u5e76\u53d6\u6d88\u6ce8\u91ca\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/li>\n<\/ul>\n<pre>root:x:0:0:root:\/root:\/bin\/bash<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u4fdd\u5b58\u5e76\u9000\u51fa\u6587\u4ef6\u3002<\/li>\n<li>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8bbe\u7f6e root \u5bc6\u7801\uff1a<\/li>\n<\/ul>\n<pre>passwd root<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8f93\u5165\u5e76\u786e\u8ba4\u60a8\u7684\u65b0\u5bc6\u7801\u3002root \u7528\u6237\u73b0\u5728\u5df2\u542f\u7528\u3002<\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n<ul>\n<li>\u59cb\u7ec8\u8c28\u614e\u4f7f\u7528 root \u6743\u9650\uff0c\u56e0\u4e3a\u5b83\u4eec\u53ef\u80fd\u4f1a\u5bf9\u60a8\u7684\u7cfb\u7edf\u9020\u6210\u635f\u574f\u3002<\/li>\n<li>\u5728\u5b8c\u6210\u9700\u8981 root \u6743\u9650\u7684\u4efb\u52a1\u540e\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9000\u51fa root \u6743\u9650\uff1a<\/li>\n<\/ul>\n<pre>exit<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f7\u600e\u4e48\u83b7\u53d6root\u6743\u9650\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8FDCServers\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\u53ef\u83b7\u53d6 centos 7 \u4e2d\u7684 root \u6743\u9650\uff1a 1. \u4f7f\u7528 &#8220;su&#8221; \u8fd0\u884c\u547d\u4ee4\u3002 2. \u4f7f\u7528 &#8220;sudo&#8221; \u8fd0\u884c\u5355\u4e2a\u547d\u4ee4\u3002 3. \u542f\u7528 root \u7528\u6237\u5e76\u8bbe\u7f6e\u5bc6\u7801\u3002\u6ce8\u610f\uff1a\u4f7f\u7528 root \u6743\u9650\u65f6\u8981\u8c28\u614e\uff0c\u56e0\u4e3a\u5b83\u4eec\u53ef\u80fd\u4f1a\u635f\u574f\u7cfb\u7edf\u3002 \u5982\u4f55\u5728 CentOS 7 \u4e2d\u83b7\u53d6 root \u6743\u9650 \u8981\u83b7\u53d6 CentOS 7 \u4e2d\u7684 root \u6743\u9650\uff0c\u6709\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a 1. \u4f7f\u7528\u201csu\u201d \u201csu\u201d\u547d\u4ee4\u5141\u8bb8\u7528\u6237\u5728\u63d0\u5347\u7279\u6743\u7684\u60c5\u51b5\u4e0b\u8fd0\u884c\u547d\u4ee4\u3002\u8981\u4f7f\u7528\u5b83\uff0c\u8bf7\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a su \u767b\u5f55\u540e\u590d\u5236 \u7cfb\u7edf\u5c06\u63d0\u793a\u60a8\u8f93\u5165 root \u5bc6\u7801\u3002\u8f93\u5165\u5bc6\u7801\u540e\uff0c\u60a8\u5c06\u83b7\u5f97 root \u6743\u9650\u3002 2. \u4f7f\u7528 sudo \u201csudo\u201d\u547d\u4ee4\u5141\u8bb8\u7528\u6237\u4ee5 root \u6743\u9650\u8fd0\u884c\u5355\u4e2a\u547d\u4ee4\u3002\u8981\u4f7f\u7528\u5b83\uff0c\u8bf7\u5728\u547d\u4ee4\u524d\u8f93\u5165\u201csudo\u201d\uff0c\u5982\u4e0b\u6240\u793a\uff1a sudo &lt;command&gt; \u767b\u5f55\u540e\u590d\u5236 \u7cfb\u7edf\u5c06\u63d0\u793a\u60a8\u8f93\u5165\u60a8\u7684\u7528\u6237\u5bc6\u7801\u3002\u8f93\u5165\u5bc6\u7801\u540e\uff0c\u60a8\u53ef\u4ee5\u8fd0\u884c\u8be5\u547d\u4ee4\u3002 3. \u542f\u7528 root [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-63467","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63467","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=63467"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63467\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=63467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=63467"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=63467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}