{"id":153126,"date":"2019-08-22T09:39:20","date_gmt":"2019-08-22T01:39:20","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=153126"},"modified":"2019-08-09T16:40:10","modified_gmt":"2019-08-09T08:40:10","slug":"file-linux","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/file-linux.html","title":{"rendered":"\u6587\u4ef6\u8bbf\u95ee\u548c\u5171\u4eab\u7684\u65b9\u6cd5\u4ecb\u7ecd"},"content":{"rendered":"
\u7b26\u53f7\u4e0e\u516b\u8fdb\u5236<\/strong><\/div>\n

\u5728\u4e0a\u4e00\u7bc7\u6587\u7ae0\u4e2d\uff0c\u4f60\u4e86\u89e3\u5230\u6587\u4ef6\u6709\u4e09\u4e2a\u4e0d\u540c\u7684\u6743\u9650\u96c6\u3002\u62e5\u6709\u8be5\u6587\u4ef6\u7684\u7528\u6237\u6709\u4e00\u4e2a\u96c6\u5408\uff0c\u62e5\u6709\u8be5\u6587\u4ef6\u7684\u7ec4\u7684\u6210\u5458\u6709\u4e00\u4e2a\u96c6\u5408\uff0c\u7136\u540e\u6700\u7ec8\u4e00\u4e2a\u96c6\u5408\u9002\u7528\u4e8e\u5176\u4ed6\u6240\u6709\u4eba\u3002\u5728\u957f\u5217\u8868\uff08ls -l\uff09\u4e2d\u8fd9\u4e9b\u6743\u9650\u4f7f\u7528\u7b26\u53f7\u6a21\u5f0f\u663e\u793a\u5728\u5c4f\u5e55\u4e0a\u3002<\/p>\n

\u6bcf\u4e2a\u96c6\u5408\u90fd\u6709 r\u3001w \u548c x \u6761\u76ee\uff0c\u8868\u793a\u7279\u5b9a\u7528\u6237\uff08\u6240\u6709\u8005\u3001\u7ec4\u6210\u5458\u6216\u5176\u4ed6\uff09\u662f\u5426\u53ef\u4ee5\u8bfb\u53d6\u3001\u5199\u5165\u6216\u6267\u884c\u8be5\u6587\u4ef6\u3002\u4f46\u662f\u8fd8\u6709\u53e6\u4e00\u79cd\u8868\u8fbe\u8fd9\u4e9b\u6743\u9650\u7684\u65b9\u6cd5\uff1a\u516b\u8fdb\u5236\u6a21\u5f0f\u3002<\/p>\n

\u4f60\u5df2\u7ecf\u4e60\u60ef\u4e86\u5341\u8fdb\u5236\u7f16\u53f7\u7cfb\u7edf\uff0c\u5b83\u6709\u5341\u4e2a\u4e0d\u540c\u7684\u503c\uff080 \u5230 9\uff09\u3002\u53e6\u4e00\u65b9\u9762\uff0c\u516b\u8fdb\u5236\u7cfb\u7edf\u6709\u516b\u4e2a\u4e0d\u540c\u7684\u503c\uff080 \u5230 7\uff09\u3002\u5728\u8868\u793a\u6743\u9650\u65f6\uff0c\u516b\u8fdb\u5236\u7528\u4f5c\u901f\u8bb0\u6765\u663e\u793a r\u3001w \u548c x \u5b57\u6bb5\u7684\u503c\u3002\u5c06\u6bcf\u4e2a\u5b57\u6bb5\u89c6\u4e3a\u5177\u6709\u5982\u4e0b\u503c\uff1a<\/p>\n

r = 4\r\nw = 2\r\nx = 1<\/pre>\n

\u73b0\u5728\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u5355\u4e2a\u516b\u8fdb\u5236\u503c\u8868\u8fbe\u4efb\u4f55\u7ec4\u5408\u3002\u4f8b\u5982\uff0c\u8bfb\u53d6\u548c\u5199\u5165\u6743\u9650\uff08\u4f46\u6ca1\u6709\u6267\u884c\u6743\u9650\uff09\u7684\u503c\u4e3a 6\u3002\u8bfb\u53d6\u548c\u6267\u884c\u6743\u9650\u7684\u503c\u4ec5\u4e3a 5\u3002\u6587\u4ef6\u7684 rwxr-xr-x \u7b26\u53f7\u6743\u9650\u7684\u516b\u8fdb\u5236\u503c\u4e3a 755\u3002<\/p>\n

\u4e0e\u7b26\u53f7\u503c\u7c7b\u4f3c\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u516b\u8fdb\u5236\u503c\u4f7f\u7528 chmod \u547d\u4ee4\u8bbe\u7f6e\u6587\u4ef6\u6743\u9650\u3002\u4ee5\u4e0b\u4e24\u4e2a\u547d\u4ee4\u5bf9\u6587\u4ef6\u8bbe\u7f6e\u76f8\u540c\u7684\u6743\u9650\uff1a<\/p>\n

chmod u=rw,g=r,o=r myfile1\r\nchmod 644 myfile1<\/pre>\n
\u7279\u6b8a\u6743\u9650\u4f4d<\/strong><\/div>\n

\u6587\u4ef6\u4e0a\u8fd8\u6709\u51e0\u4e2a\u7279\u6b8a\u6743\u9650\u4f4d\u3002\u8fd9\u4e9b\u88ab\u79f0\u4e3a setuid\uff08\u6216 suid\uff09\u3001setgid\uff08\u6216 sgid\uff09\uff0c\u4ee5\u53ca\u7c98\u6ede\u4f4dsticky bit\uff08\u6216\u963b\u6b62\u5220\u9664\u4f4ddelete inhibit\uff09\u3002 \u5c06\u6b64\u89c6\u4e3a\u53e6\u4e00\u7ec4\u516b\u8fdb\u5236\u503c\uff1a<\/p>\n

setuid = 4\r\nsetgid = 2\r\nsticky = 1\r\n\u9664\u975e\u8be5\u6587\u4ef6\u662f\u53ef\u6267\u884c\u7684\uff0c\u5426\u5219 setuid \u4f4d\u662f\u88ab\u5ffd\u7565\u7684\u3002\u5982\u679c\u662f\u53ef\u6267\u884c\u7684\u8fd9\u79cd\u60c5\u51b5\uff0c\u5219\u8be5\u6587\u4ef6\uff08\u53ef\u80fd\u662f\u5e94\u7528\u7a0b\u5e8f\u6216\u811a\u672c\uff09\u7684\u8fd0\u884c\u5c31\u50cf\u62e5\u6709\u8be5\u6587\u4ef6\u7684\u7528\u6237\u542f\u52a8\u7684\u4e00\u6837\u3002setuid \u7684\u4e00\u4e2a\u5f88\u597d\u7684\u4f8b\u5b50\u662f \/bin\/passwd \u5b9e\u7528\u7a0b\u5e8f\uff0c\u5b83\u5141\u8bb8\u7528\u6237\u8bbe\u7f6e\u6216\u66f4\u6539\u5bc6\u7801\u3002\u6b64\u5b9e\u7528\u7a0b\u5e8f\u5fc5\u987b\u80fd\u591f\u5199\u5165\u5230\u4e0d\u5141\u8bb8\u666e\u901a\u7528\u6237\u66f4\u6539\u7684\u6587\u4ef6\u4e2d\uff08LCTT \u8bd1\u6ce8\uff1a\u6b64\u5904\u662f\u6307 \/etc\/passwd \u548c \/etc\/shadow\uff09\u3002\u56e0\u6b64\u5b83\u9700\u8981\u7cbe\u5fc3\u7f16\u5199\uff0c\u7531 root \u7528\u6237\u62e5\u6709\uff0c\u5e76\u5177\u6709 setuid \u4f4d\uff0c\u4ee5\u4fbf\u5b83\u53ef\u4ee5\u66f4\u6539\u5bc6\u7801\u76f8\u5173\u6587\u4ef6\u3002<\/pre>\n

setgid \u4f4d\u5bf9\u4e8e\u53ef\u6267\u884c\u6587\u4ef6\u7684\u5de5\u4f5c\u65b9\u5f0f\u7c7b\u4f3c\u3002\u8be5\u6587\u4ef6\u5c06\u4f7f\u7528\u62e5\u6709\u5b83\u7684\u7ec4\u7684\u6743\u9650\u8fd0\u884c\u3002\u4f46\u662f\uff0csetgid \u5bf9\u4e8e\u76ee\u5f55\u8fd8\u6709\u4e00\u4e2a\u989d\u5916\u7684\u7528\u9014\u3002\u5982\u679c\u5728\u5177\u6709 setgid \u6743\u9650\u7684\u76ee\u5f55\u4e2d\u521b\u5efa\u6587\u4ef6\uff0c\u5219\u8be5\u6587\u4ef6\u7684\u7ec4\u6240\u6709\u8005\u5c06\u8bbe\u7f6e\u4e3a\u8be5\u76ee\u5f55\u7684\u7ec4\u6240\u6709\u8005\u3002<\/p>\n

\u6700\u540e\uff0c\u867d\u7136\u6587\u4ef6\u7c98\u6ede\u4f4d\u6ca1\u6709\u610f\u4e49\u4f1a\u88ab\u5ffd\u7565\uff0c\u4f46\u5b83\u5bf9\u76ee\u5f55\u5f88\u6709\u7528\u3002\u5728\u76ee\u5f55\u4e0a\u8bbe\u7f6e\u7684\u7c98\u6ede\u4f4d\u5c06\u963b\u6b62\u7528\u6237\u5220\u9664\u5176\u4ed6\u7528\u6237\u62e5\u6709\u7684\u8be5\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6\u3002<\/p>\n

\u5728\u516b\u8fdb\u5236\u6a21\u5f0f\u4e0b\u4f7f\u7528 chmod \u8bbe\u7f6e\u8fd9\u4e9b\u4f4d\u7684\u65b9\u6cd5\u662f\u6dfb\u52a0\u4e00\u4e2a\u503c\u524d\u7f00\uff0c\u4f8b\u5982 4755\uff0c\u53ef\u4ee5\u5c06 setuid \u6dfb\u52a0\u5230\u53ef\u6267\u884c\u6587\u4ef6\u4e2d\u3002\u5728\u7b26\u53f7\u6a21\u5f0f\u4e0b\uff0cu \u548c g \u4e5f\u53ef\u7528\u4e8e\u8bbe\u7f6e\u6216\u5220\u9664 setuid \u548c setgid\uff0c\u4f8b\u5982 u+s,g+s\u3002\u7c98\u6ede\u4f4d\u4f7f\u7528 o+t \u8bbe\u7f6e\u3002\uff08\u5176\u4ed6\u7684\u7ec4\u5408\uff0c\u5982 o+s \u6216 u+t\uff0c\u662f\u6ca1\u6709\u610f\u4e49\u7684\uff0c\u4f1a\u88ab\u5ffd\u7565\u3002\uff09<\/p>\n

\u5171\u4eab\u4e0e\u7279\u6b8a\u6743\u9650<\/strong><\/div>\n

\u56de\u60f3\u4e00\u4e0b\u524d\u4e00\u7bc7\u6587\u7ae0\u4e2d\u5173\u4e8e\u9700\u8981\u5171\u4eab\u6587\u4ef6\u7684\u8d22\u52a1\u56e2\u961f\u7684\u793a\u4f8b\u3002\u53ef\u4ee5\u60f3\u8c61\uff0c\u7279\u6b8a\u6743\u9650\u4f4d\u6709\u52a9\u4e8e\u66f4\u6709\u6548\u5730\u89e3\u51b3\u95ee\u9898\u3002\u539f\u6765\u7684\u89e3\u51b3\u65b9\u6848\u53ea\u662f\u521b\u5efa\u4e86\u4e00\u4e2a\u6574\u4e2a\u7ec4\u53ef\u4ee5\u5199\u5165\u7684\u76ee\u5f55\uff1a<\/p>\n

drwxrwx---. 2 root finance 4096 Jul 6 15:35 finance\r\n\u6b64\u76ee\u5f55\u7684\u4e00\u4e2a\u95ee\u9898\u662f\uff0cfinance \u7ec4\u6210\u5458\u7684\u7528\u6237 dwayne \u548c jill \u53ef\u4ee5\u5220\u9664\u5f7c\u6b64\u7684\u6587\u4ef6\u3002\u8fd9\u5bf9\u4e8e\u5171\u4eab\u7a7a\u95f4\u6765\u8bf4\u4e0d\u662f\u6700\u4f73\u9009\u62e9\u3002\u5b83\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u53ef\u80fd\u6709\u7528\uff0c\u4f46\u5728\u5904\u7406\u8d22\u52a1\u8bb0\u5f55\u65f6\u53ef\u80fd\u4e0d\u4f1a\uff01<\/pre>\n

\u53e6\u4e00\u4e2a\u95ee\u9898\u662f\u6b64\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6\u53ef\u80fd\u65e0\u6cd5\u771f\u6b63\u5171\u4eab\uff0c\u56e0\u4e3a\u5b83\u4eec\u5c06\u7531 dwayne \u548c jill \u7684\u9ed8\u8ba4\u7ec4\u62e5\u6709 - \u5f88\u53ef\u80fd\u7528\u6237\u79c1\u6709\u7ec4\u4e5f\u547d\u540d\u4e3a dwayne \u548c jill\uff0c\u800c\u4e0d\u662f finance\u3002<\/p>\n

\u89e3\u51b3\u6b64\u95ee\u9898\u7684\u66f4\u597d\u65b9\u6cd5\u662f\u5728\u6587\u4ef6\u5939\u4e0a\u8bbe\u7f6e setgid \u548c\u7c98\u6ede\u4f4d\u3002\u8fd9\u5c06\u505a\u4e24\u4ef6\u4e8b\uff1a\u4f7f\u6587\u4ef6\u5939\u4e2d\u521b\u5efa\u7684\u6587\u4ef6\u81ea\u52a8\u5f52 finance \u7ec4\u6240\u6709\uff0c\u5e76\u9632\u6b62 dwayne \u548c jill \u5220\u9664\u5f7c\u6b64\u7684\u6587\u4ef6\u3002\u4e0b\u9762\u8fd9\u4e9b\u547d\u4ee4\u4e2d\u7684\u4efb\u4f55\u4e00\u4e2a\u90fd\u53ef\u4ee5\u5de5\u4f5c\uff1a<\/p>\n

sudo chmod 3770 finance\r\nsudo chmod u+rwx,g+rwxs,o+t finance\r\n\u8be5\u6587\u4ef6\u7684\u957f\u5217\u8868\u73b0\u5728\u663e\u793a\u4e86\u6240\u5e94\u7528\u7684\u65b0\u7279\u6b8a\u6743\u9650\u3002\u7c98\u6ede\u4f4d\u663e\u793a\u4e3a T \u800c\u4e0d\u662f t\uff0c\u56e0\u4e3a finance \u7ec4\u4e4b\u5916\u7684\u7528\u6237\u65e0\u6cd5\u641c\u7d22\u8be5\u6587\u4ef6\u5939\u3002<\/pre>\n
drwxrws--T. 2 root finance 4096 Jul 6 15:35 finance<\/pre>\n
\n

via: https:\/\/fedoramagazine.org\/command-line-quick-tips-more-about-permissions\/<\/a><\/p>\n

\u4f5c\u8005\uff1aPaul W. Frields<\/a> \u9009\u9898\uff1alujun9972<\/a> \u8bd1\u8005\uff1awxy<\/a> \u6821\u5bf9\uff1awxy<\/a><\/p>\n

\u672c\u6587\u7531 LCTT<\/a> \u539f\u521b\u7f16\u8bd1\uff0cLinux\u4e2d\u56fd<\/a> \u8363\u8a89\u63a8\u51fa<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5728\u4e0a\u4e00\u7bc7\u6587\u7ae0\u4e2d\uff0c\u4f60\u4e86\u89e3\u5230\u6587\u4ef6\u6709\u4e09\u4e2a\u4e0d\u540c\u7684\u6743\u9650\u96c6\u3002\u62e5\u6709\u8be5\u6587\u4ef6\u7684\u7528\u6237\u6709\u4e00\u4e2a\u96c6\u5408\uff0c\u62e5\u6709\u8be5\u6587\u4ef6\u7684\u7ec4\u7684\u6210\u5458\u6709\u4e00\u4e2a\u96c6\u5408\uff0c\u7136 […]<\/p>\n","protected":false},"author":323,"featured_media":136263,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-153126","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/153126","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/323"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=153126"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/153126\/revisions"}],"predecessor-version":[{"id":153349,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/153126\/revisions\/153349"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/136263"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=153126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=153126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=153126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}