{"id":6027,"date":"2024-08-22T08:01:01","date_gmt":"2024-08-22T00:01:01","guid":{"rendered":""},"modified":"2024-08-22T08:01:01","modified_gmt":"2024-08-22T00:01:01","slug":"linux\u6587\u4ef6\u9ed8\u8ba4\u8bbf\u95ee\u6743\u9650_chmod\u4fee\u6539\u6587\u4ef6\u5939\u4e0b\u6240\u6709\u6587\u4ef6\u6743\u9650","status":"publish","type":"post","link":"https:\/\/mushiming.com\/6027.html","title":{"rendered":"linux\u6587\u4ef6\u9ed8\u8ba4\u8bbf\u95ee\u6743\u9650_chmod\u4fee\u6539\u6587\u4ef6\u5939\u4e0b\u6240\u6709\u6587\u4ef6\u6743\u9650"},"content":{"rendered":"

\n <\/path> \n<\/svg> <\/p>\n

\u4e00.\u6587\u4ef6\u7684\u9ed8\u8ba4\u6743\u9650<\/h4>\n

1.\u5982\u679c\u4e0d\u52a0\u4ee5\u4fee\u6539\uff0cLinux\u4e2d\u65b0\u5efa\u4e00\u4e2a\u6587\u4ef6\u4ee5\u53ca\u76ee\u5f55\u7684\u9ed8\u8ba4\u6743\u9650\u662f\uff1a
\"linux\u6587\u4ef6\u9ed8\u8ba4\u8bbf\u95ee\u6743\u9650_chmod\u4fee\u6539\u6587\u4ef6\u5939\u4e0b\u6240\u6709\u6587\u4ef6\u6743\u9650
\u5bf9\u4e8e\u76ee\u5f55\uff0c\u9ed8\u8ba4\u6743\u9650=777-umask
\u5bf9\u4e8e\u6587\u4ef6\uff0c\u9ed8\u8ba4\u6743\u9650=666-umask\uff08\u6587\u4ef6\u9ed8\u8ba4\u65e0\u6267\u884c\u6743\u9650\uff09
2.uamsk\u7684\u4fee\u6539<\/p>\n

vim \/etc\/bashrc 71<\/span>\u884c\u662f\u666e\u901a\u7528\u6237\u7684\u66f4\u6539\uff0c73<\/span>\u662f\u8d85\u7ea7\u7528\u6237\u7684\u66f4\u6539 vim \/etc\/profile 60<\/span>\u884c\u662f\u666e\u901a\u7528\u6237\u7684\u66f4\u6539\uff0c62<\/span>\u662f\u8d85\u7ea7\u7528\u6237\u7684\u66f4\u6539 source<\/span> \/etc\/bashrc ##\u5237\u65b0bash\u914d\u7f6e<\/span> source<\/span> \/etc\/profile ##\u5237\u65b0\u7cfb\u7edf\u914d\u7f6e<\/span><\/code><\/pre>\n
\u4e8c.\u7279\u6b8a\u6743\u9650(stickyid\/sgid\/suid)<\/h5>\n
stickyid ###\u5f3a\u5236\u4f4d<\/span> o+t ###\u4e4b\u9488\u5bf9\u76ee\u5f55\uff0c\u5f53\u4e00\u4e2a\u76ee\u5f55\u4e0a\u6709t\u6743\u9650\u65f6\uff0c\u8fd9\u4e2a\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6\u53ea\u80fd\u88ab\u6587\u4ef6\u62e5\u6709\u8005\u5220\u9664<\/span> t=1<\/span> chmod o+t directroy chmod 1777<\/span> directory<\/span> sgid ###\u7c98\u5236\u4f4d<\/span> g+s ##\u9488\u5bf9\u76ee\u5f55\uff0c\u5728\u76ee\u5f55\u4e2d\u521b\u5efa\u7684\u6587\u4ef6\u90fd\u81ea\u52a8\u5f52\u5c5e\u5230\u76ee\u5f55\u6240\u5728\u7ec4\uff0c\u9488\u5bf9\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u6587\u4ef6\u5185\u8bb0\u5f55\u7684\u7a0b\u5e8f\u5728\u6267\u884c\u65f6\u548c\u6267\u884c\u8005\u7684\u7ec4\u8eab\u4efd\u6ca1\u6709\u5173\u7cfb\uff0c\u800c\u662f\u4ee5\u4e8c\u8fdb\u5236\u6587\u4ef6\u7684\u6240\u6709\u7ec4\u7684\u8eab\u4efd\u6267\u884c\u7684<\/span> chmod g+s file<\/span>|directory<\/span> chmod 2777<\/span> file<\/span>|directory<\/span> suid ###\u5192\u9669\u4f4d<\/span> u+s ###\u9488\u5bf9\u6587\u4ef6\uff0c\u6587\u4ef6\u8bb0\u5f55\u52a8\u4f5c\u5728\u6267\u884c\u65f6\u662f\u4ee5\u6587\u4ef6\u6240\u6709\u4eba\u8eab\u4efd\u6267\u884c\u7684\uff0c\u4e0e\u662f\u8c01\u53d1\u8d77\u7684\u65e0\u5173<\/span> chmod u+s file<\/span> chmod 4777<\/span> file<\/span><\/code><\/pre>\n

\u4e09.\u7ec6\u90e8\u6743\u9650\u89c4\u5212<\/h4>\n

1.\u4ec0\u4e48\u662fACL\uff08Access Control list\u6743\u9650\u5217\u8868\uff09
\u5bf9\u6587\u4ef6\u7684\u6743\u9650\u8fdb\u884c\u9644\u52a0\u8bf4\u660e\u7684\u6743\u9650\u8bbe\u5b9a\u65b9\u5f0f
2.ACL\u63d0\u4f9b\u4f20\u7edf\u7684owner\/group\/other\u7684read\/write\/execute\u4e4b\u5916\u7684\u7ec6\u90e8\u6743\u9650\u8bbe\u5b9a\u3002\uff08\u53ef\u4ee5\u9488\u5bf9\u5355\u4e00\u7684\u4f7f\u7528\u8005\uff0c\u76ee\u5f55\u7b49\u7b49\uff09
3.\u5982\u4f55\u67e5\u770b\u6743\u9650\u5217\u8868\uff1a<\/p>\n

[root@aclhost<\/span> mnt]# ls<\/span> -l file<\/span> -rw-r--r--. 1<\/span> root root 0<\/span> Nov 7<\/span> 09<\/span>:14<\/span> file<\/span> | \u5982\u679c\u6b64\u4f4d\u4e3a\u201c.\u201d,\u4ee3\u8868\u8fd9\u4f4d\u4e0a\u6ca1\u6709\u6743\u9650\u5217\u8868 \u5982\u679c\u6b64\u4f4d\u4e3a\u201c+\u201d,\u4ee3\u8868\u6743\u9650\u6743\u9650\u5217\u8868\u5b58\u5728<\/code><\/pre>\n

\"linux\u6587\u4ef6\u9ed8\u8ba4\u8bbf\u95ee\u6743\u9650_chmod\u4fee\u6539\u6587\u4ef6\u5939\u4e0b\u6240\u6709\u6587\u4ef6\u6743\u9650<\/p>\n

[root@aclhost<\/span> mnt]# getfacl file <\/span> # file: file ##\u6587\u4ef6\u540d\u79f0<\/span> # owner: root ##\u6587\u4ef6\u6240\u6709\u4eba<\/span> # group: root ##\u6587\u4ef6\u6240\u6709\u7ec4<\/span> user:<\/span>:rw-<\/span> ##\u6240\u6709\u4eba\u6743\u9650<\/span> user:<\/span>student:<\/span>rw- ##\u7279\u5b9a\u7528\u6237\u6743\u9650<\/span> group:<\/span>:r--<\/span> ##\u6240\u6709\u7ec4\u6743\u9650<\/span> mask:<\/span>:rw-<\/span> ##\u7279\u5b9a\u7528\u6237\u751f\u6548\u7684\u6700\u5927\u6743\u9650<\/span> other:<\/span>:r--<\/span> ##\u5176\u4ed6\u4eba\u6743\u9650<\/span> <\/code><\/pre>\n

4.1 \u5982\u4f55\u8bbe\u5b9aACL\u6743\u9650\uff1a<\/p>\n

setfacl setfacl -m <u|g|m>:<username|groupname><\/span>:<\/span>\u6743\u9650 filename ##\u8bbe\u5b9aacl<\/span> setfacl -x <u|g>:<username|groupname><\/span> filename ##\u53bb\u9664\u67d0\u4e2a\u7528\u6237\u6216\u8005\u7ec4\u7684acl<\/span> setfacl -b filename ##\u5220\u9664\u6587\u4ef6\u4e0a\u7684\u6743\u9650\u5217\u8868<\/span> <\/code><\/pre>\n

\"linux\u6587\u4ef6\u9ed8\u8ba4\u8bbf\u95ee\u6743\u9650_chmod\u4fee\u6539\u6587\u4ef6\u5939\u4e0b\u6240\u6709\u6587\u4ef6\u6743\u9650<\/p>\n

4.2 ACL\u9ed8\u8ba4\u6743\u9650<\/p>\n

\u9ed8\u8ba4\u6743\u9650\u9488\u5bf9\u76ee\u5f55\u4f7f\u7528\uff0c\u662f\u8ba9\u76ee\u5f55\u4e2d\u6240\u6709\u65b0\u5efa\u6587\u4ef6\u90fd\u7ee7\u627f\u6b64\u6743\u9650\uff0c\u8fd9\u4e2a\u6743\u9650\u5bf9\u76ee\u5f55\u672c\u8eab\u4e0d\u751f\u6548\uff0c\u5e76\u4e14\u4e0d\u4f1a\u5f71\u54cd\u76ee\u5f55\u4e2d\u5df2\u7ecf\u5b58\u5728\u7684\u6587\u4ef6 setfacl -m d:<\/span><u|g|o>:<username|group><\/span>:rwx<\/span> directory ##\u8bbe\u5b9a\u9ed8\u8ba4\u6743\u9650<\/span> setfacl -x d:<\/span><u|g|o>:<username|group><\/span> directory ##\u64a4\u9500\u76ee\u5f55\u4e2d\u7684\u67d0\u6761\u9ed8\u8ba4\u6743\u9650<\/span> <\/code><\/pre>\n

\"linux\u6587\u4ef6\u9ed8\u8ba4\u8bbf\u95ee\u6743\u9650_chmod\u4fee\u6539\u6587\u4ef6\u5939\u4e0b\u6240\u6709\u6587\u4ef6\u6743\u9650<\/p>\n

\"linux\u6587\u4ef6\u9ed8\u8ba4\u8bbf\u95ee\u6743\u9650_chmod\u4fee\u6539\u6587\u4ef6\u5939\u4e0b\u6240\u6709\u6587\u4ef6\u6743\u9650
4.3 mask\u662f\u4ec0\u4e48\u4e1c\u897f\uff1f
\u6709\u6548\u6743\u9650\uff1a\u7528\u6237or\u7ec4\u6240\u8bbe\u7f6e\u7684\u6743\u9650\u5fc5\u987b\u8981\u5b58\u5728\u4e8emask\u7684\u6743\u9650\u8bbe\u7f6e\u8303\u56f4\u5185\u624d\u4f1a\u751f\u6548\u3002
\"linux\u6587\u4ef6\u9ed8\u8ba4\u8bbf\u95ee\u6743\u9650_chmod\u4fee\u6539\u6587\u4ef6\u5939\u4e0b\u6240\u6709\u6587\u4ef6\u6743\u9650<\/p>\n

5.\u5728\u6bd4\u5982rhel6\u4ee5\u53ca\u4e4b\u524d\u7684\u7248\u672c\u4e2d\uff0c\u7528\u6237\u5efa\u7acb\u7684\u5206\u533a\u65f6\u4e0d\u652f\u6301acl\u7684\uff0c\u5982\u679c\u9700\u8981\uff0c\u5fc5\u987b\u52a0\u8f7dacl\u53c2\u6570<\/p>\n

mount -o remount\uff0cacl \u8bbe\u5907<\/span> vim \/etc\/fstab \u8bbe\u5907 \u6302\u8f7d\u70b9 \u7c7b\u578b defaults\uff0cacl 0<\/span> 0<\/span><\/code><\/pre>\n
\n

5.1\u67e5\u770b\u6587\u4ef6\u7cfb\u7edf\u662f\u5426\u652f\u6301ACL
xfs\u6587\u4ef6\u7cfb\u7edf\u5df2\u7ecf\u9ed8\u8ba4\/\u5f3a\u5236\u5f00\u542f\u4e86ACL\uff0c\u4e0d\u7528\u5728mount\u65f6\u589e\u52a0\u53c2\u6570acl\uff0c\u5728fstab\u52a0acl\u53c2\u6570\u65f6\u4f1a\u62a5\u9519\uff08acl\u662f\u4e0d\u8bc6\u522b\u9009\u9879\uff09
\"linux\u6587\u4ef6\u9ed8\u8ba4\u8bbf\u95ee\u6743\u9650_chmod\u4fee\u6539\u6587\u4ef6\u5939\u4e0b\u6240\u6709\u6587\u4ef6\u6743\u9650
\uff08\u540c\u6b65\u6587\u4ef6\u7cfb\u7edf\u64cd\u4f5c\uff09<\/p>\n<\/blockquote>\n

ext\u7cfb\u7edf\u53ef\u4ee5\u4f7f\u7528<\/p>\n

dumpe2fs -h<\/span> \u67e5\u770bacl\u662f\u5426\u5f00\u542f<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"linux\u6587\u4ef6\u9ed8\u8ba4\u8bbf\u95ee\u6743\u9650_chmod\u4fee\u6539\u6587\u4ef6\u5939\u4e0b\u6240\u6709\u6587\u4ef6\u6743\u9650\u4e00.\u6587\u4ef6\u7684\u9ed8\u8ba4\u6743\u96501.\u5982\u679c\u4e0d\u52a0\u4ee5\u4fee\u6539\uff0cLinux\u4e2d\u65b0\u5efa\u4e00\u4e2a\u6587\u4ef6\u4ee5\u53ca\u76ee\u5f55\u7684\u9ed8...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/6027"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=6027"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/6027\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=6027"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=6027"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=6027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}