{"id":63015,"date":"2025-04-29T08:33:35","date_gmt":"2025-04-29T00:33:35","guid":{"rendered":"https:\/\/fwq.ai\/blog\/63015\/"},"modified":"2025-04-29T08:33:35","modified_gmt":"2025-04-29T00:33:35","slug":"%e4%ba%86%e8%a7%a3selinux%e7%9a%84%e4%b8%8d%e5%90%8c%e5%b7%a5%e4%bd%9c%e6%a8%a1%e5%bc%8f-3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/63015\/","title":{"rendered":"\u4e86\u89e3SELinux\u7684\u4e0d\u540c\u5de5\u4f5c\u6a21\u5f0f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/887\/227\/170893084065626.jpg\" class=\"aligncenter\" title=\"\u4e86\u89e3SELinux\u7684\u4e0d\u540c\u5de5\u4f5c\u6a21\u5f0f\u63d2\u56fe\" alt=\"\u4e86\u89e3SELinux\u7684\u4e0d\u540c\u5de5\u4f5c\u6a21\u5f0f\u63d2\u56fe\" \/><\/p>\n<p>SELinux\u662f\u4e00\u79cd\u5b89\u5168\u589e\u5f3a\u578bLinux\uff0c\u5b83\u7684\u5168\u79f0\u662fSecurity-Enhanced Linux\uff0c\u662f\u4e00\u4e2aLinux\u5185\u6838\u7684\u5b89\u5168\u6a21\u5757\u3002\u5b83\u80fd\u591f\u63d0\u4f9b\u5f3a\u5236\u8bbf\u95ee\u63a7\u5236\u529f\u80fd\uff0c\u901a\u8fc7\u5f3a\u5236\u8bbf\u95ee\u63a7\u5236\u53ef\u4ee5\u66f4\u597d\u5730\u4fdd\u62a4\u7cfb\u7edf\u7684\u5b89\u5168\u6027\u3002SELinux\u901a\u8fc7\u5bf9\u8fdb\u7a0b\u8bbf\u95ee\u8d44\u6e90\u7684\u6743\u9650\u63a7\u5236\uff0c\u53ef\u4ee5\u6709\u6548\u963b\u6b62\u6076\u610f\u7a0b\u5e8f\u5bf9\u7cfb\u7edf\u8d44\u6e90\u7684\u6ee5\u7528\u3002<\/p>\n<p>\u5728SELinux\u4e2d\uff0c\u6709\u4e09\u79cd\u5de5\u4f5c\u6a21\u5f0f\uff1aEnforcing\u3001Permissive\u548cDisabled\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e09\u79cd\u5de5\u4f5c\u6a21\u5f0f\uff0c\u5e76\u4e14\u63d0\u4f9b\u5177\u4f53\u7684\u4ee3\u7801\u793a\u4f8b\u3002<\/p>\n<ol>\n<li>\n<p>Enforcing\u6a21\u5f0f<br \/> Enforcing\u6a21\u5f0f\u662fSELinux\u7684\u9ed8\u8ba4\u5de5\u4f5c\u6a21\u5f0f\u3002\u5728\u8fd9\u79cd\u6a21\u5f0f\u4e0b\uff0cSELinux\u4f1a\u5f3a\u5236\u6267\u884c\u7b56\u7565\u5e76\u963b\u6b62\u8fdd\u53cd\u7b56\u7565\u7684\u884c\u4e3a\u3002\u5982\u679c\u4e00\u4e2a\u8fdb\u7a0b\u8bd5\u56fe\u6267\u884c\u672a\u7ecf\u6388\u6743\u7684\u64cd\u4f5c\uff0cSELinux\u4f1a\u963b\u6b62\u8be5\u64cd\u4f5c\u5e76\u751f\u6210\u76f8\u5e94\u7684\u544a\u8b66\u3002\u5728Enforcing\u6a21\u5f0f\u4e0b\uff0c\u7cfb\u7edf\u7ba1\u7406\u5458\u53ef\u4ee5\u67e5\u770b\u5e76\u5206\u6790SELinux\u7684\u544a\u8b66\u65e5\u5fd7\uff0c\u4ee5\u53ca\u6839\u636e\u9700\u8981\u66f4\u65b0SELinux\u7b56\u7565\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4ee3\u7801\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u67e5\u770b\u5f53\u524dSELinux\u7684\u5de5\u4f5c\u6a21\u5f0f\u5e76\u5c06\u5176\u8bbe\u7f6e\u4e3aEnforcing\u6a21\u5f0f\uff1a<\/p>\n<pre># \u67e5\u770b\u5f53\u524dSELinux\u6a21\u5f0f\ngetenforce\n\n# \u5c06SELinux\u8bbe\u7f6e\u4e3aEnforcing\u6a21\u5f0f\nsetenforce 1<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/li>\n<li>\n<p>Permissive\u6a21\u5f0f<br \/> Permissive\u6a21\u5f0f\u662fSELinux\u7684\u4e00\u79cd\u5de5\u4f5c\u6a21\u5f0f\uff0c\u4e0eEnforcing\u6a21\u5f0f\u76f8\u6bd4\uff0cPermissive\u6a21\u5f0f\u4e0d\u4f1a\u5f3a\u5236\u6267\u884c\u7b56\u7565\uff0c\u800c\u662f\u4ec5\u8bb0\u5f55\u8fdd\u53cd\u7b56\u7565\u7684\u884c\u4e3a\u5e76\u751f\u6210\u8b66\u544a\u3002\u5728\u8fd9\u79cd\u6a21\u5f0f\u4e0b\uff0c\u7cfb\u7edf\u7ba1\u7406\u5458\u53ef\u4ee5\u67e5\u770bSELinux\u7684\u544a\u8b66\u65e5\u5fd7\uff0c\u4f46\u4e0d\u4f1a\u963b\u6b62\u672a\u7ecf\u6388\u6743\u7684\u64cd\u4f5c\u3002Permissive\u6a21\u5f0f\u901a\u5e38\u7528\u4e8e\u8c03\u8bd5\u548c\u5206\u6790SELinux\u7684\u7b56\u7565\uff0c\u4ee5\u4fbf\u5728\u4e0d\u5f71\u54cd\u7cfb\u7edf\u6b63\u5e38\u8fd0\u884c\u7684\u60c5\u51b5\u4e0b\u8fdb\u884c\u8c03\u6574\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4ee3\u7801\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u5c06SELinux\u8bbe\u7f6e\u4e3aPermissive\u6a21\u5f0f\uff1a<\/p>\n<pre># \u5c06SELinux\u8bbe\u7f6e\u4e3aPermissive\u6a21\u5f0f\nsetenforce 0<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/li>\n<li>\n<p>Disabled\u6a21\u5f0f<br \/> Disabled\u6a21\u5f0f\u662fSELinux\u7684\u5de5\u4f5c\u6a21\u5f0f\u4e4b\u4e00\uff0c\u5b83\u5c06\u5b8c\u5168\u7981\u7528SELinux\u7684\u529f\u80fd\u3002\u5728\u8fd9\u79cd\u6a21\u5f0f\u4e0b\uff0c\u7cfb\u7edf\u5c06\u4e0d\u4f1a\u6267\u884cSELinux\u7684\u4efb\u4f55\u7b56\u7565\uff0c\u4e5f\u4e0d\u4f1a\u751f\u6210\u4efb\u4f55\u544a\u8b66\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u4e0d\u63a8\u8350\u5c06SELinux\u8bbe\u7f6e\u4e3aDisabled\u6a21\u5f0f\uff0c\u56e0\u4e3a\u8fd9\u4f1a\u964d\u4f4e\u7cfb\u7edf\u7684\u5b89\u5168\u6027\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4ee3\u7801\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u5c06SELinux\u8bbe\u7f6e\u4e3aDisabled\u6a21\u5f0f\uff1a<\/p>\n<pre># \u5c06SELinux\u8bbe\u7f6e\u4e3aDisabled\u6a21\u5f0f\nsetenforce 0<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/li>\n<\/ol>\n<p>\u7efc\u4e0a\u6240\u8ff0\uff0cSELinux\u6709\u4e09\u79cd\u5de5\u4f5c\u6a21\u5f0f\uff1aEnforcing\u3001Permissive\u548cDisabled\u3002\u7cfb\u7edf\u7ba1\u7406\u5458\u53ef\u4ee5\u6839\u636e\u9700\u8981\u9009\u62e9\u9002\u5408\u7684\u5de5\u4f5c\u6a21\u5f0f\uff0c\u4ee5\u786e\u4fdd\u7cfb\u7edf\u7684\u5b89\u5168\u6027\u548c\u7a33\u5b9a\u6027\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u60c5\u51b5\u9009\u62e9\u5408\u9002\u7684\u6a21\u5f0f\uff0c\u5e76\u6839\u636e\u9700\u8981\u8c03\u6574SELinux\u7684\u7b56\u7565\uff0c\u4ee5\u63d0\u9ad8\u7cfb\u7edf\u7684\u5b89\u5168\u6027\u548c\u53ef\u9760\u6027\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4e86\u89e3SELinux\u7684\u4e0d\u540c\u5de5\u4f5c\u6a21\u5f0f\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>SELinux\u662f\u4e00\u79cd\u5b89\u5168\u589e\u5f3a\u578bLinux\uff0c\u5b83\u7684\u5168\u79f0\u662fSecurity-Enhanced Linux\uff0c\u662f\u4e00\u4e2aLinux\u5185\u6838\u7684\u5b89\u5168\u6a21\u5757\u3002\u5b83\u80fd\u591f\u63d0\u4f9b\u5f3a\u5236\u8bbf\u95ee\u63a7\u5236\u529f\u80fd\uff0c\u901a\u8fc7\u5f3a\u5236\u8bbf\u95ee\u63a7\u5236\u53ef\u4ee5\u66f4\u597d\u5730\u4fdd\u62a4\u7cfb\u7edf\u7684\u5b89\u5168\u6027\u3002SELinux\u901a\u8fc7\u5bf9\u8fdb\u7a0b\u8bbf\u95ee\u8d44\u6e90\u7684\u6743\u9650\u63a7\u5236\uff0c\u53ef\u4ee5\u6709\u6548\u963b\u6b62\u6076\u610f\u7a0b\u5e8f\u5bf9\u7cfb\u7edf\u8d44\u6e90\u7684\u6ee5\u7528\u3002 \u5728SELinux\u4e2d\uff0c\u6709\u4e09\u79cd\u5de5\u4f5c\u6a21\u5f0f\uff1aEnforcing\u3001Permissive\u548cDisabled\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e09\u79cd\u5de5\u4f5c\u6a21\u5f0f\uff0c\u5e76\u4e14\u63d0\u4f9b\u5177\u4f53\u7684\u4ee3\u7801\u793a\u4f8b\u3002 Enforcing\u6a21\u5f0f Enforcing\u6a21\u5f0f\u662fSELinux\u7684\u9ed8\u8ba4\u5de5\u4f5c\u6a21\u5f0f\u3002\u5728\u8fd9\u79cd\u6a21\u5f0f\u4e0b\uff0cSELinux\u4f1a\u5f3a\u5236\u6267\u884c\u7b56\u7565\u5e76\u963b\u6b62\u8fdd\u53cd\u7b56\u7565\u7684\u884c\u4e3a\u3002\u5982\u679c\u4e00\u4e2a\u8fdb\u7a0b\u8bd5\u56fe\u6267\u884c\u672a\u7ecf\u6388\u6743\u7684\u64cd\u4f5c\uff0cSELinux\u4f1a\u963b\u6b62\u8be5\u64cd\u4f5c\u5e76\u751f\u6210\u76f8\u5e94\u7684\u544a\u8b66\u3002\u5728Enforcing\u6a21\u5f0f\u4e0b\uff0c\u7cfb\u7edf\u7ba1\u7406\u5458\u53ef\u4ee5\u67e5\u770b\u5e76\u5206\u6790SELinux\u7684\u544a\u8b66\u65e5\u5fd7\uff0c\u4ee5\u53ca\u6839\u636e\u9700\u8981\u66f4\u65b0SELinux\u7b56\u7565\u3002 \u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4ee3\u7801\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u67e5\u770b\u5f53\u524dSELinux\u7684\u5de5\u4f5c\u6a21\u5f0f\u5e76\u5c06\u5176\u8bbe\u7f6e\u4e3aEnforcing\u6a21\u5f0f\uff1a # \u67e5\u770b\u5f53\u524dSELinux\u6a21\u5f0f getenforce # \u5c06SELinux\u8bbe\u7f6e\u4e3aEnforcing\u6a21\u5f0f setenforce 1 \u767b\u5f55\u540e\u590d\u5236 Permissive\u6a21\u5f0f Permissive\u6a21\u5f0f\u662fSELinux\u7684\u4e00\u79cd\u5de5\u4f5c\u6a21\u5f0f\uff0c\u4e0eEnforcing\u6a21\u5f0f\u76f8\u6bd4\uff0cPermissive\u6a21\u5f0f\u4e0d\u4f1a\u5f3a\u5236\u6267\u884c\u7b56\u7565\uff0c\u800c\u662f\u4ec5\u8bb0\u5f55\u8fdd\u53cd\u7b56\u7565\u7684\u884c\u4e3a\u5e76\u751f\u6210\u8b66\u544a\u3002\u5728\u8fd9\u79cd\u6a21\u5f0f\u4e0b\uff0c\u7cfb\u7edf\u7ba1\u7406\u5458\u53ef\u4ee5\u67e5\u770bSELinux\u7684\u544a\u8b66\u65e5\u5fd7\uff0c\u4f46\u4e0d\u4f1a\u963b\u6b62\u672a\u7ecf\u6388\u6743\u7684\u64cd\u4f5c\u3002Permissive\u6a21\u5f0f\u901a\u5e38\u7528\u4e8e\u8c03\u8bd5\u548c\u5206\u6790SELinux\u7684\u7b56\u7565\uff0c\u4ee5\u4fbf\u5728\u4e0d\u5f71\u54cd\u7cfb\u7edf\u6b63\u5e38\u8fd0\u884c\u7684\u60c5\u51b5\u4e0b\u8fdb\u884c\u8c03\u6574\u3002 \u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4ee3\u7801\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u5c06SELinux\u8bbe\u7f6e\u4e3aPermissive\u6a21\u5f0f\uff1a # \u5c06SELinux\u8bbe\u7f6e\u4e3aPermissive\u6a21\u5f0f setenforce 0 \u767b\u5f55\u540e\u590d\u5236 Disabled\u6a21\u5f0f Disabled\u6a21\u5f0f\u662fSELinux\u7684\u5de5\u4f5c\u6a21\u5f0f\u4e4b\u4e00\uff0c\u5b83\u5c06\u5b8c\u5168\u7981\u7528SELinux\u7684\u529f\u80fd\u3002\u5728\u8fd9\u79cd\u6a21\u5f0f\u4e0b\uff0c\u7cfb\u7edf\u5c06\u4e0d\u4f1a\u6267\u884cSELinux\u7684\u4efb\u4f55\u7b56\u7565\uff0c\u4e5f\u4e0d\u4f1a\u751f\u6210\u4efb\u4f55\u544a\u8b66\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u4e0d\u63a8\u8350\u5c06SELinux\u8bbe\u7f6e\u4e3aDisabled\u6a21\u5f0f\uff0c\u56e0\u4e3a\u8fd9\u4f1a\u964d\u4f4e\u7cfb\u7edf\u7684\u5b89\u5168\u6027\u3002 \u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4ee3\u7801\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u5c06SELinux\u8bbe\u7f6e\u4e3aDisabled\u6a21\u5f0f\uff1a # \u5c06SELinux\u8bbe\u7f6e\u4e3aDisabled\u6a21\u5f0f setenforce 0 \u767b\u5f55\u540e\u590d\u5236 \u7efc\u4e0a\u6240\u8ff0\uff0cSELinux\u6709\u4e09\u79cd\u5de5\u4f5c\u6a21\u5f0f\uff1aEnforcing\u3001Permissive\u548cDisabled\u3002\u7cfb\u7edf\u7ba1\u7406\u5458\u53ef\u4ee5\u6839\u636e\u9700\u8981\u9009\u62e9\u9002\u5408\u7684\u5de5\u4f5c\u6a21\u5f0f\uff0c\u4ee5\u786e\u4fdd\u7cfb\u7edf\u7684\u5b89\u5168\u6027\u548c\u7a33\u5b9a\u6027\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u60c5\u51b5\u9009\u62e9\u5408\u9002\u7684\u6a21\u5f0f\uff0c\u5e76\u6839\u636e\u9700\u8981\u8c03\u6574SELinux\u7684\u7b56\u7565\uff0c\u4ee5\u63d0\u9ad8\u7cfb\u7edf\u7684\u5b89\u5168\u6027\u548c\u53ef\u9760\u6027\u3002 \u4ee5\u4e0a\u5c31\u662f\u4e86\u89e3SELinux\u7684\u4e0d\u540c\u5de5\u4f5c\u6a21\u5f0f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8FDCServers\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/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-63015","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63015","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=63015"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63015\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=63015"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=63015"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=63015"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}