{"id":241896,"date":"2022-05-12T08:18:49","date_gmt":"2022-05-12T00:18:49","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=241896"},"modified":"2022-05-04T19:10:44","modified_gmt":"2022-05-04T11:10:44","slug":"linux-chmod-command","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-chmod-command.html","title":{"rendered":"\u7b80\u8ff0Linux chmod\u547d\u4ee4\u7684\u77e5\u8bc6"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nchmod\u7528\u4e8e\u7ba1\u7406\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u6743\u9650\uff0c\u6587\u4ef6\u6216\u76ee\u5f55\u6743\u9650\u7684\u63a7\u5236\u5206\u522b\u4ee5\u8bfb\u53d6(r)\u3001\u5199\u5165(w)\u3001\u6267\u884c(x)3\u79cd\u53ef\u8bfb\u53ef\u5199\u53ef\u6267\u884c\uff0c\u62bd\u8c61\u7684\u7528\u4e8c\u8fdb\u5236\u6765\u8868\u793a 1 \u4ee3\u8868\u62e5\u6709\u8be5\u6743\u9650\uff0c0 \u4ee3\u8868\u6ca1\u6709\u8be5\u6743\u9650\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u770b\u5230\u5177\u6709\u5168\u90e8\u6743\u9650\u4e8c\u8fdb\u5236\u53ef\u7406\u89e3\u4e3a \u201c111\u201d \u5373 \u5341\u8fdb\u5236\u7684 \u201c7\u201d\uff0c\u53ea\u6709\u8bfb\u5199\u6743\u9650\u4e8c\u8fdb\u5236\u53ef\u7406\u89e3\u4e3a \u201c100\u201d \u5373 \u5341\u8fdb\u5236\u7684 \u201c4\u201d\u4ee5\u6b64\u7c7b\u63a8\uff0c\u5176\u5b83\u7684\u4e00\u81f4\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
1\u3001\u6743\u9650\u8303\u56f4<\/strong><\/div>\n

u,User\u3000\u3000\u3000 \u5373\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u62e5\u6709\u8005
\ng,Group\u3000\u3000\u3000\u5373\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u6240\u5c5e\u7fa4\u7ec4
\no,Other\u3000\u3000\u3000 \u9664\u4e86\u6587\u4ef6\u6216\u76ee\u5f55\u62e5\u6709\u8005\u6216\u6240\u5c5e\u7fa4\u7ec4\u4e4b\u5916\uff0c\u5176\u4ed6\u7528\u6237\u7686\u5c5e\u4e8e\u8fd9\u4e2a\u8303\u56f4
\na,All\u3000\u3000\u3000\u3000 \u5373\u5168\u90e8\u7684\u7528\u6237\uff0c\u5305\u542b\u62e5\u6709\u8005\uff0c\u6240\u5c5e\u7fa4\u7ec4\u4ee5\u53ca\u5176\u4ed6\u7528\u6237
\nr\u3000\u3000\u3000\u3000\u3000\u3000 \u8bfb\u53d6\u6743\u9650\uff0c\u6570\u5b57\u4ee3\u53f7\u4e3a\u201c4\u201d \u5373 \u201c100\u201d
\nw\u3000\u3000\u3000\u3000\u3000\u3000\u5199\u5165\u6743\u9650\uff0c\u6570\u5b57\u4ee3\u53f7\u4e3a\u201c2\u201d \u5373 \u201c010\u201d
\nx\u3000\u3000\u3000\u3000\u3000\u3000 \u6267\u884c\u6216\u5207\u6362\u6743\u9650\uff0c\u6570\u5b57\u4ee3\u53f7\u4e3a\u201c1\u201d \u5373 \u201c001\u201d
\n-\u3000\u3000\u3000\u3000\u3000\u3000 \u4e0d\u5177\u4efb\u4f55\u6743\u9650\uff0c\u6570\u5b57\u4ee3\u53f7\u4e3a\u201c0\u201d \u5373 \u201c000\u201d<\/p>\n

2\u3001\u7528\u6cd5<\/strong><\/div>\n

chmod [\u9009\u9879] [\u6587\u4ef6..]<\/p>\n

3\u3001\u76ee\u5f55\u9009\u9879<\/strong><\/div>\n

-c,--changes\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000 \u6548\u679c\u7c7b\u4f3c\u201c-v\u201d\u53c2\u6570\uff0c\u4f46\u4ec5\u56de\u62a5\u66f4\u6539\u7684\u90e8\u5206
\n-f,--quiet,--silent\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000 \u4e0d\u663e\u793a\u9519\u8bef\u4fe1\u606f
\n-R,--recursive\u3000\u3000\u3000\u3000\u3000\u3000\u3000 \u3000 \u9012\u5f52\u5904\u7406\uff0c\u5c06\u6307\u4ee4\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u6587\u4ef6\u53ca\u5b50\u76ee\u5f55\u4e00\u5e76\u5904\u7406
\n-v,--verbose\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u663e\u793a\u6307\u4ee4\u6267\u884c\u8fc7\u7a0b
\n--reference=\u3000 \u3000\u3000\u3000\u3000\u3000 \u628a\u6307\u5b9a\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u6240\u5c5e\u7fa4\u7ec4\u5168\u90e8\u8bbe\u6210\u548c\u53c2\u8003\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u6240\u5c5e\u7fa4\u7ec4\u76f8\u540c
\n<\u6743\u9650\u8303\u56f4>+<\u6743\u9650>\u3000\u3000 \u3000\u3000 \u589e\u52a0\u6307\u5b9a\u6743\u9650 (chmod u+r file)
\n<\u6743\u9650\u8303\u56f4>-<\u6743\u9650>\u3000\u3000 \u3000\u3000\u3000\u3000\u5220\u9664\u6307\u5b9a\u6743\u9650 (chmod g-rw file)
\n<\u6743\u9650\u8303\u56f4>=<\u6743\u9650>\u3000\u3000\u3000\u3000\u3000\u3000 \u7b49\u4e8e\u6307\u5b9a\u6743\u9650 (chmod o=rwx file)<\/file><\/p>\n

4\u3001\u5b9e\u4f8b<\/strong><\/div>\n
1\uff09\u589e\u52a01.txt \u6240\u5c5e\u7ec4\u7684 \u5199 \u6743\u9650<\/strong><\/span><\/div>\n
# ll 1.txt<\/pre>\n

-rw-r--r--. 1 root root 0 8\u6708 25 21:36 1.txt<\/p>\n

# chmod g+w 1.txt\r\n# ll 1.txt<\/pre>\n

-rw-rw-r--. 1 root root 0 8\u6708 25 21:36 1.txt<\/p>\n

2\uff09\u5220\u9664 2.txt \u5176\u4ed6\u7528\u6237\u7684 \u8bfb \u6743\u9650\uff0c\u540c\u65f6\u589e\u52a0\u6240\u5c5e\u7ec4\u7684\u5199\u6743\u9650<\/strong><\/span><\/div>\n

-rw-r--r--. 1 root root 0 8\u6708 25 21:36 2.txt<\/p>\n

# chmod o-r,g+w 2.txt\r\n# ll 2.txt<\/pre>\n

-rw-rw----. 1 root root 0 8\u6708 25 21:36 2.txt<\/p>\n

3\uff09\u4fee\u6539 3.txt \u7684\u6743\u9650\u4e3a u=rwx,g=rw,o=-<\/strong><\/span><\/div>\n
# ll 3.txt<\/pre>\n

-rw-r--r--. 1 root root 0 8\u6708 25 21:36 3.txt<\/p>\n

# chmod u=rwx,g=rw,o=- 3.txt\r\n# ll 3.txt<\/pre>\n

-rwxrw----. 1 root root 0 8\u6708 25 21:36 3.txt<\/p>\n

4\uff09\u7528\u6570\u5b57 \u4fee\u6539 4.txt \u7684\u6743\u9650<\/strong><\/span><\/div>\n
# ll 4.txt<\/pre>\n

-rw-r--r--. 1 root root 0 8\u6708 23 20:55 4.txt<\/p>\n

# chmod 777 4.txt\r\n# ll 4.txt<\/pre>\n

-rwxrwxrwx. 1 root root 0 8\u6708 23 20:55 4.txt<\/p>\n

# chmod 644 4.txt\r\n# ll 4.txt<\/pre>\n

-rw-r--r--. 1 root root 0 8\u6708 23 20:55 4.txt<\/p>\n

# chmod 0 4.txt\r\n# ll 4.txt<\/pre>\n

----------. 1 root root 0 8\u6708 23 20:55 4.txt<\/p>\n

5\u3001\u8bf4\u660e<\/strong><\/span><\/div>\n

\"\"<\/p>\n

\u7b2c\u4e00\u90e8\u5206\uff1a\u7b2c 1 \u4f4d\u4e3a\u6587\u4ef6\u7c7b\u578b\uff0c2~10\u4f4d\u8868\u793a\u6587\u4ef6\u6743\u9650\uff0c234\uff1a\u7528\u6237\u6743\u9650\uff0c567\uff1a\u6240\u7ec4\u6743\u9650\uff0c789\uff1a\u5176\u5b83\u7528\u6237\u6743\u9650
\n\u3000\u3000\u3000\u3000\u3000\u6587\u4ef6\u7c7b\u578b\u8bf4\u660e -\uff1a\u666e\u901a\u6587\u4ef6\uff0cd\uff1a\u76ee\u5f55\u6587\u4ef6\uff0cb\uff1a\u5757\u8bbe\u5907\u6587\u4ef6\uff0cc\u5b57\u7b26\u8bbe\u5907\u6587\u4ef6\uff0cl\uff1a\u7b26\u53f7\u94fe\uff0cp\uff1a\u7ba1\u9053\u7279\u6b8a\u6587\u4ef6<\/p>\n

\u7b2c\u4e8c\u90e8\u5206\uff1a\u8868\u793a\u786c\u94fe\u63a5\u6570<\/p>\n

\u7b2c\u4e09\u90e8\u5206\uff1aoot\u8868\u793a\u6587\u4ef6\u62e5\u6709\u8005\uff0c\u7528\u6237\u540d<\/p>\n

\u7b2c\u56db\u90e8\u5206\uff1a root \u8868\u793a\u6587\u4ef6\u7684\u6240\u5c5e\u7ec4<\/p>\n

\u7b2c\u4e94\u90e8\u5206\uff1a\u6700\u540e\u8868\u793a\u6587\u4ef6\u7684\u6700\u540e\u4fee\u6539\u65f6\u95f4<\/p>\n

\u7b2c\u516d\u90e8\u5206\uff1a\u6587\u4ef6\u540d<\/p>\n","protected":false},"excerpt":{"rendered":"

u,User\u3000\u3000\u3000 \u5373\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u62e5\u6709\u8005 g,Group\u3000\u3000\u3000\u5373\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u6240\u5c5e\u7fa4\u7ec4 o,Other\u3000\u3000\u3000 \u9664 […]<\/p>\n","protected":false},"author":310,"featured_media":241910,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-241896","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\/241896","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\/310"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=241896"}],"version-history":[{"count":15,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/241896\/revisions"}],"predecessor-version":[{"id":242056,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/241896\/revisions\/242056"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/241910"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=241896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=241896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=241896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}