\u8be6\u60c5\u63cf\u8ff0\uff1a\nInode\u7d22\u5f15\u8282\u70b9\u7f16\u53f7\uff1a2490424\n\u6587\u4ef6\u7c7b\u578b\uff1a\u6587\u4ef6\u7c7b\u578b\u662f-\uff0c\u8868\u793a\u8fd9\u662f\u4e00\u4e2a\u666e\u901a\u6587\u4ef6\uff1b\n\u6587\u4ef6\u6743\u9650\uff1a\u6587\u4ef6\u6743\u9650\u662frw-r--r--\uff0c\u8868\u793a\u6587\u4ef6\u5c5e\u4e3b\u53ef\u8bfb\u53ef\u5199\uff1b\u6587\u4ef6\u6240\u5c5e\u7684\u7528\u6237\u7ec4\u53ef\u8bfb\uff1b\u5176\u4ed6\u7528\u6237\u53ef\u8bfb\uff1b\n\u786c\u94fe\u63a5\u4e2a\u6570\uff1a\u8868\u793aoldboy\u8fd9\u4e2a\u6587\u4ef6\u6ca1\u6709\u5176\u4ed6\u7684\u786c\u94fe\u63a5\uff1b\u56e0\u4e3a\u94fe\u63a5\u6570\u662f1\uff0c\u5c31\u662f\u4ed6\u672c\u8eab\uff1b\n\u6587\u4ef6\u5c5e\u4e3b\uff1a\u8fd9\u4e2a\u6587\u4ef6\u6240\u5c5e\u7684\u7528\u6237\uff0c\u8fd9\u91cc\u610f\u601d\u662fk8s-init.sh\u6587\u4ef6\u88abroot\u62e5\u6709\uff0c\u662f\u7b2c\u4e00\u4e2aroot\uff1b\n\u6587\u4ef6\u5c5e\u7ec4\uff1a\u8fd9\u4e2a\u6587\u4ef6\u6240\u5c5e\u7684\u7528\u6237\u7ec4\uff0c\u5728\u8fd9\u91cc\u662froot\u7528\u6237\u7ec4\uff0c\u662f\u7b2c\u4e8c\u4e2aroot\uff1b\n\u6587\u4ef6\u5927\u5c0f\uff1a\u6587\u4ef6\u5927\u5c0f\u662f4.4K\uff1b\n\u6587\u4ef6\u4fee\u6539\u65f6\u95f4\uff1a\u8fd9\u91cc\u7684\u65f6\u95f4\u662f\u8be5\u6587\u4ef6\u7684\u6700\u540e\u88ab\u66f4\u65b0\uff08\u5305\u62ec\u6587\u4ef6\u521b\u5efa\u3001\u5185\u5bb9\u66f4\u65b0\u3001\u6587\u4ef6\u540d\u66f4\u65b0\u7b49\uff09\uff0c\u53ef\u7528\u5982\u4e0b\u547d\u4ee4\u67e5\u770b\u6587\u4ef6\u7684\u4fee\u6539\uff0c\u8bbf\u95ee\uff0c\u521b\u5efa\u7684\u65f6\u95f4\uff1b<\/code><\/pre>\n\u7d22\u5f15\u8282\u70b9inode<\/h2>\n \n inode\u4e2d\u6587\u610f\u601d\u662f\u7d22\u5f15\u8282\u70b9\uff0c\u6bcf\u4e2a\u5b58\u50a8\u8bbe\u5907\u6216\u5b58\u50a8\u8bbe\u5907\u7684\u5206\u533a\uff08\u5b58\u50a8\u8bbe\u5907\u53ef\u4ee5\u662f\u786c\u76d8\u3001U\u76d8....\uff09\u88ab\u683c\u5f0f\u5316\u4e3a\u6587\u4ef6\u7cfb\u7edf\u540e\uff0c\u90fd\u5e94\u8be5\u6709\u4e24\u90e8\u5206\uff1a\u4e00\u90e8\u5206\u662finode\uff0c\u53e6\u4e00\u90e8\u5206\u662fBlock\u3002Block\u662f\u7528\u6765\u5b58\u50a8\u6570\u636e\u7528\u7684\u3002\u800cinode\u5c31\u662f\u7528\u6765\u5b58\u50a8\u8fd9\u4e9b\u6570\u636e\u4fe1\u606f\u7684\uff0c\u8fd9\u4e9b\u4fe1\u606f\u5305\u62ec\u6587\u4ef6\u5927\u5c0f\u3001\u5c5e\u4e3b\u3001\u5f52\u5c5e\u7684\u7528\u6237\u7ec4\u3001\u8bfb\u5199\u6743\u9650\u3002<\/p>\n
inode\u4e3a\u6bcf\u4e2a\u6587\u4ef6\u8fdb\u884c\u4fe1\u606f\u7d22\u5f15\uff0c\u6240\u4ee5\u5c31\u6709\u4e86inode\u7684\u6570\u503c\u3002\u64cd\u4f5c\u7cfb\u7edf\u6839\u636e\u6307\u4ee4\uff0c\u80fd\u901a\u8fc7inode\u503c\u6700\u5feb\u7684\u627e\u5230\u76f8\u5bf9\u5e94\u7684\u6587\u4ef6\u3002<\/p>\n
\u6253\u4e2a\u6bd4\u65b9\uff0c\u6bd4\u5982\u4e00\u672c\u4e66\uff0c\u5b58\u50a8\u8bbe\u5907\u6216\u5206\u533a\u5c31\u76f8\u5f53\u4e8e\u8fd9\u672c\u4e66\uff0cBlock\u76f8\u5f53\u4e8e\u4e66\u4e2d\u7684\u6bcf\u4e00\u9875\uff0cinode\u5c31\u76f8\u5f53\u4e8e\u8fd9\u672c\u4e66\u524d\u9762\u7684\u76ee\u5f55\uff0c\u4e00\u672c\u4e66\u6709\u5f88\u591a\u5185\u5bb9\uff0c\u5982\u679c\u60f3\u67e5\u627e\u67d0\u90e8\u5206\u7684\u5185\u5bb9\uff0c\u53ef\u4ee5\u5148\u67e5\u76ee\u5f55\uff0c\u901a\u8fc7\u76ee\u5f55\u66f4\u5feb\u7684\u627e\u5230\u6211\u4eec\u60f3\u8981\u770b\u7684\u5185\u5bb9\u3002\u867d\u7136\u4e0d\u592a\u6070\u5f53\uff0c\u4f46\u8fd8\u662f\u6bd4\u8f83\u5f62\u8c61\u7684\u3002<\/p>\n
\u5f53\u7528ls\u67e5\u770b\u67d0\u4e2a\u76ee\u5f55\u6216\u6587\u4ef6\u65f6\uff0c\u5982\u679c\u52a0\u4e0a-i\u53c2\u6570\uff0c\u5c31\u53ef\u4ee5\u770b\u5230inode\u8282\u70b9\u4e86\uff1b\u6bd4\u5982\uff1a<\/p>\n
<\/p>\n
\u7b2c\u4e00\u5217inode\u503c\u662f810407\uff1b\u67e5\u770b\u4e00\u4e2a\u6587\u4ef6\u6216\u76ee\u5f55\u7684inode\uff0c\u901a\u8fc7ls\u547d\u4ee4\u7684-i\u53c2\u6570\u5373\u53ef\u3002<\/p>\n
inode\u503c\u76f8\u540c\u7684\u6587\u4ef6\u662f\u786c\u94fe\u63a5\u6587\u4ef6<\/h3>\n \u5728linux\u6587\u4ef6\u7cfb\u7edf\u4e2d\uff0cinode\u503c\u76f8\u540c\u7684\u6587\u4ef6\u662f\u786c\u94fe\u63a5\u6587\u4ef6\u3002\u8fd9\u4e5f\u5c31\u662f\u8bf4\uff0c\u4e0d\u540c\u7684\u6587\u4ef6\u540d\uff0cinode\u7684\u503c\u53ef\u80fd\u662f\u76f8\u540c\u7684\uff0c\u4e00\u4e2ainode\u503c\u53ef\u4ee5\u5bf9\u4e8e\u591a\u4e2a\u6587\u4ef6\u3002\u5728Linux\u4e2d\uff0c\u94fe\u63a5\u6587\u4ef6\u662f\u901a\u8fc7ln\u547d\u4ee4\u6765\u521b\u5efa\u7684\u3002<\/p>\n
\u786c\u94fe\u63a5\u7684\u539f\u7406\u53ca\u793a\u4f8b:<\/h3>\n \n \u7528ln\u521b\u5efa\u6587\u4ef6\u786c\u94fe\u63a5\u7684\u8bed\u6cd5\uff1a<\/p>\n
#ln \u6e90\u6587\u4ef6 \u76ee\u6807\u6587\u4ef6 #\u6ce8\u610f\uff1a\u76ee\u6807\u6587\u4ef6\u4e0d\u9700\u8981\u63d0\u524d\u521b\u5efa<\/code><\/pre>\n\u4e0b\u9762\u4e3e\u4e00\u4e2a\u4f8b\u5b50:<\/p>\n
<\/p>\n
\u53ef\u4ee5\u770b\u5230oldboy\u5728\u6ca1\u6709\u521b\u5efa\u786c\u94fe\u63a5\u6587\u4ef6oldboy_hard_link\u7684\u65f6\u5019\uff0c\u5176\u94fe\u63a5\u4e2a\u6570\u662f1\uff0c\u521b\u5efa\u4e86\u786c\u94fe\u63a5oldboy_hard_link\u540e\uff0c\u8fd9\u4e2a\u503c\u5c31\u53d8\u4e3a2\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u6211\u4eec\u6bcf\u6b21\u4e3aoldboy\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u786c\u94fe\u63a5\u6587\u4ef6\u540e\uff0c\u5176\u786c\u94fe\u63a5\u4e2a\u6570\u90fd\u4f1a\u589e\u52a01.<\/p>\n
inode\u503c\u76f8\u540c\u7684\u6587\u4ef6\uff0c\u53ef\u4ee5\u628a\u4ed6\u4eec\u7684\u5173\u7cfb\u770b\u4f5c\u4e92\u4e3a\u786c\u94fe\u63a5\u7684\u5173\u7cfb\u3002\u5f53\u6211\u4eec\u4fee\u6539\u5176\u4e2d\u4e00\u4e2a\u6587\u4ef6\u7684\u5185\u5bb9\u65f6\uff0c\u4e92\u4e3a\u786c\u94fe\u63a5\u7684\u6587\u4ef6\u7684\u5185\u5bb9\u4e5f\u4f1a\u8ddf\u7740\u53d8\u5316\u3002\u5982\u679c\u6211\u4eec\u5220\u9664\u4e92\u4e3a\u786c\u94fe\u63a5\u5173\u7cfb\u7684\u67d0\u4e2a\u6587\u4ef6\u65f6\uff0c\u53e6\u5916\u7684\u786c\u94fe\u63a5\u5e76\u4e0d\u53d7\u5f71\u54cd\uff0c\u65e2\u6587\u4ef6\u6570\u636e\u8fd8\u5728\uff08\u5f53\u6587\u4ef6\u786c\u94fe\u63a5\u4e2a\u6570\u4e3a0\u65f6\uff0c\u6570\u636e\u5360\u7528\u7a7a\u95f4\u624d\u4f1a\u88ab\u91ca\u653e\u56de\u6536\uff09\u3002\u5982\u6211\u4eec\u628aoldboy\u6587\u4ef6\u5220\u9664\u540e\uff0c\u6211\u4eec\u8fd8\u662f\u4e00\u6837\u80fd\u770b\u5230oldboy_hard_link\u7684\u5185\u5bb9\uff0c\u5e76\u4e14oldboy_hard_link\u4ecd\u662f\u5b58\u5728\u7684\u3002<\/p>\n
\u53ef\u4ee5\u8fd9\u6837\u7406\u89e3\uff0c\u4e92\u4e3a\u786c\u94fe\u63a5\u5173\u7cfb\u7684\u6587\u4ef6\uff0c\u5177\u6709\u76f8\u540c\u7684inode\u503c\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5bf9\u5e94\u7684\u5b9e\u9645\u6570\u636e\u662f\u540c\u4e00\u4efd\uff1b\u4e0b\u9762\u7684\u4f8b\u5b50\u6211\u4eec\u628aoldboy\u6e90\u6587\u4ef6\u5220\u9664\uff0c\u7136\u540e\u770b\u4e00\u4e0b\u554aoldboy_hard_link\u662f\u4e0d\u662f\u80fd\u770b\u5230\u5176\u5185\u5bb9\u3002<\/p>\n
<\/p>\n
\n\u7279\u522b\u63d0\u793a\uff1a\u76ee\u5f55\u4e0d\u80fd\u521b\u5efa\u786c\u94fe\u63a5\uff0c\u53ea\u6709\u6587\u4ef6\u624d\u80fd\u521b\u5efa\u786c\u94fe\u63a5\u3002<\/p>\n<\/blockquote>\n
\u8f6f\u94fe\u63a5\u7684\u539f\u7406\u53ca\u793a\u4f8b\uff1a<\/h3>\n \n \u521b\u5efa\u8f6f\u94fe\u63a5\uff08\u4e5f\u79f0\u4e3a\u7b26\u53f7\u94fe\u63a5\uff09\u7684\u8bed\u6cd5\uff1a<\/p>\n
#ln -s \u6e90\u6587\u4ef6\u6216\u76ee\u5f55 \u76ee\u6807\u6587\u4ef6\u6216\u76ee\u5f55<\/code><\/pre>\n\u8f6f\u94fe\u63a5\u4e5f\u53eb\u7b26\u53f7\u94fe\u63a5\uff0c\u5b83\u548c\u786c\u94fe\u63a5\u6709\u6240\u4e0d\u540c\uff0c\u8f6f\u94fe\u63a5\u6587\u4ef6\uff08\u5305\u542b\u5230\u6e90\u6587\u4ef6\u7684\u8def\u5f84\u4f4d\u7f6e\u7b49\u4fe1\u606f\uff09\u3002\u5f53\u6211\u4eec\u5220\u9664\u4e86\u6e90\u6587\u4ef6\u540e\uff0c\u8f6f\u94fe\u63a5\u5c31\u4e0d\u80fd\u72ec\u7acb\u5b58\u5728\u4e86\u3002\u867d\u7136\u4ecd\u7136\u4f1a\u4fdd\u7559\u6587\u4ef6\u540d\uff08\u5931\u6548\u540e\u67e5\u770b\u65f6\u4f1a\u662f\u7ea2\u8272\u95ea\u70c1\u72b6\uff09\uff0c\u4f46\u6211\u4eec\u5374\u4e0d\u80fd\u67e5\u770b\u8f6f\u94fe\u63a5\u7684\u5185\u5bb9\u4e86\u3002<\/p>\n
<\/p>\n
\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u67e5\u770b\u4e0betiantian.txt\u7684\u5c5e\u6027\uff0c\u6bd4\u5982\u6587\u4ef6\u7684inode\u3001\u6240\u5c5e\u6587\u4ef6\u7c7b\u578b\u3001\u521b\u5efa\u6216\u4fee\u6539\u65f6\u95f4\u7b49...\uff0c\u6211\u4eec\u6765\u5bf9\u6bd4\u4e00\u4e0b\uff1a<\/p>\n
1.\u5bf9\u6bd4\u4e00\u4e0b\u8282\u70b9\uff1a\u4e24\u4e2a\u6587\u4ef6\u7684inode\u8282\u70b9\u503c\u4e0d\u540c\uff1b\n2.\u4e24\u4e2a\u6587\u4ef6\u7684\u6587\u4ef6\u7c7b\u578b\u4e0d\u540cetiantian.txt\u662f-\uff08\u8868\u793a\u666e\u901a\u6587\u4ef6\uff09\uff0c\u800cetiantian_soft_link.txt \u662fl(\u5b57\u6bcdl\u8868\u793a\u94fe\u63a5\u6587\u4ef6)\uff1b\n3.\u4e24\u4e2a\u6587\u4ef6\u7684\u8bfb\u5199\u6743\u9650\u4e0d\u540cetiantian.txt\u662f-rw-r--r--\uff0c\u800cetiantian_soft_link.txt\u7684\u8bfb\u5199\u6743\u9650\u662frwxrwxrwx\n4.\u4e24\u4e2a\u6587\u4ef6\u7684\u786c\u94fe\u63a5\u4e2a\u6570\u76f8\u540c\uff1b\u90fd\u662f1\n5.\u4e24\u4e2a\u6587\u4ef6\u7684\u5c5e\u4e3b\u548c\u6240\u5f52\u5c5e\u7684\u7528\u6237\u7ec4\u76f8\u540c\uff1b\n6.\u4e24\u4e2a\u6587\u4ef6\u7684\u521b\u5efa\u6216\u4fee\u6539\u7684\u65f6\u95f4\u5217\u4e0d\u540c\uff1b<\/code><\/pre>\n\u6211\u4eec\u8fd8\u6ce8\u610f\u5e26\u4e86etiantian.txt\u540e\u9762\u6709\u4e00\u4e2a\u6807\u8bb0\u201d.>\u201d,\u8fd9\u8868\u793aetiantian_soft_link.txt<\/strong>\u662fetiantian.txt<\/strong>\u7684\u8f6f\u94fe\u63a5\u6587\u4ef6\u3002<\/p>\n\u7279\u522b\u63d0\u9192\uff1a<\/p>\n
\u5f53\u6211\u4eec\u4fee\u6539\u94fe\u63a5\u6587\u4ef6\u7684\u5185\u5bb9\u65f6\uff0c\u5c31\u610f\u5473\u7740\u6211\u4eec\u5728\u4fee\u6539\u6e90\u6587\u4ef6\u7684\u5185\u5bb9\u3002\u6b64\u65f6\u6e90\u6587\u4ef6\u7684\u5c5e\u6027\u4e5f\u4f1a\u53d1\u751f\u6539\u53d8\uff0c\u4f46\u8f6f\u94fe\u63a5\u6587\u4ef6\u7684\u5c5e\u6027\u5e76\u4e0d\u4f1a\u53d1\u751f\u53d8\u5316\u3002\u5982\u6211\u4eec\u628a\u6e90\u6587\u4ef6\u5220\u9664\u540e\uff0c\u5219\u94fe\u63a5\u6587\u4ef6\u53ea\u4f1a\u5b58\u5728\u4e00\u4e2a\u5931\u6548\u7684\u6587\u4ef6\u540d\uff0c\u56e0\u4e3a\u5931\u53bb\u4e86\u6e90\u6587\u4ef6\uff0c\u6240\u4ee5\u8f6f\u94fe\u63a5\u4e5f\u5c31\u4e0d\u5b58\u5728\u4e86\u3002\u8fd9\u4e00\u70b9\u548c\u786c\u94fe\u63a5\u662f\u4e0d\u540c\u7684\uff1b<\/p>\n
<\/p>\n
\u4ece\u4e0a\u9762\u7684\u4f8b\u5b50\u53ef\u4ee5\u770b\u51fa\uff0c\u5982\u679c\u4e00\u4e2a\u94fe\u63a5\u6587\u4ef6\u5931\u53bb\u4e86\u6e90\u6587\u4ef6\uff0c\u5b83\u5c31\u5df2\u7ecf\u4e0d\u5b58\u5728\u4e86\uff1b\u867d\u7136\u4ecd\u4f1a\u4fdd\u7559\u6587\u4ef6\u540d\uff08\u5931\u6548\u540e\u67e5\u770b\u65f6\u4f1a\u662f\u7ea2\u8272\u95ea\u70c1\u72b6\uff09\uff0c\u4e5f\u65e0\u6cd5\u8bbf\u95ee\u5230\u6587\u4ef6\u4e86\u3002<\/p>\n
\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u8f6f\u94fe\u63a5\u6587\u4ef6\u5176\u5b9e\u76f8\u5f53\u4e8e\u6e90\u6587\u4ef6\u7684\u4e00\u4e2a\u5feb\u6377\u65b9\u5f0f\uff0c\u5f53\u6e90\u6587\u4ef6\u5931\u53bb\u65f6\uff0c\u5b83\u4e5f\u5c31\u4e0d\u5b58\u5728\u4e86\u3002\u8f6f\u94fe\u63a5\u6587\u4ef6\u53ea\u662f\u5360\u7528\u4e86inode\u6765\u5b58\u50a8\u8f6f\u94fe\u63a5\u6587\u4ef6\u5c5e\u6027\u7b49\u4fe1\u606f\uff0c\u4f46\u6587\u4ef6\u5185\u5bb9\u5b58\u50a8\u662f\u6307\u5411\u6e90\u6587\u4ef6\u7684\u3002<\/p>\n
\u4e0e\u786c\u94fe\u63a5\u4e0d\u540c\u7684\u662f\uff0c\u8f6f\u94fe\u63a5\u5bf9\u6587\u4ef6\u548c\u76ee\u5f55\u90fd\u9002\u7528\u3002\u65e0\u8bba\u662f\u8f6f\u94fe\u63a5\u8fd8\u662f\u786c\u94fe\u63a5\uff0c\u90fd\u76f8\u5f53\u4e8e\u7269\u4ef6\u6216\u76ee\u5f55\uff0c\u56e0\u6b64\u90fd\u53ef\u4ee5\u7528rm\u547d\u4ee4\u6765\u5220\u9664\u3002<\/p>\n
\u6587\u4ef6\u7c7b\u578b\u53ca\u6743\u9650<\/h2>\n \n \u5728Linux\u4e2d\u6587\u4ef6\u7c7b\u578b\u53ef\u4ee5\u662f \u76ee\u5f55\u3001\u6587\u4ef6\u6216\u94fe\u63a5\u6587\u4ef6<\/strong> \u7b49\u7b49<\/p>\n\n\u5982\u679c\u4e3a[ d<\/strong> ]\uff0c\u5219\u662f\u76ee\u5f55<\/li>\n\u5982\u679c\u4e3a[ -<\/strong> ]\uff0c\u5219\u662f\u6587\u4ef6<\/li>\n\u5982\u679c\u4e3a[ l<\/strong> ]\uff0c\u5219\u8868\u793a\u4e3a\u94fe\u63a5\u6587\u6863(link file)<\/li>\n\u5982\u679c\u4e3a[ b<\/strong> ]\uff0c\u5219\u8868\u793a\u4e3a\u88c5\u7f6e\u6587\u4ef6\u91cc\u9762\u7684\u53ef\u4f9b\u50a8\u5b58\u7684\u63a5\u53e3\u8bbe\u5907(\u53ef\u968f\u673a\u5b58\u53d6\u88c5\u7f6e)<\/li>\n\u5982\u679c\u4e3a[ c<\/strong> ]\uff0c\u5219\u8868\u793a\u4e3a\u88c5\u7f6e\u6587\u4ef6\u91cc\u9762\u7684\u4e32\u884c\u7aef\u53e3\u8bbe\u5907\uff0c\u4f8b\u5982\u952e\u76d8\u3001\u9f20\u6807(\u4e00\u6b21\u6027\u8bfb\u53d6\u88c5\u7f6e)<\/li>\n<\/ul>\n\u63a5\u4e0b\u6765\u7684\u5b57\u7b26\u4e2d\uff0c\u4ee5\u4e09\u4e2a\u4e3a\u4e00\u7ec4\uff0c\u4e14\u5747\u4e3a\u300erwx\u300f \u7684\u4e09\u4e2a\u53c2\u6570\u7684\u7ec4\u5408\u3002<\/p>\n
\u5176\u4e2d\uff0c[ r ]\u4ee3\u8868\u53ef\u8bfb(read)\u3001[ w ]\u4ee3\u8868\u53ef\u5199(write)\u3001[ x ]\u4ee3\u8868\u53ef\u6267\u884c(execute)\u3002<\/p>\n
\n\u6ce8\u610f\uff1a \u8fd9\u4e09\u4e2a\u6743\u9650\u7684\u4f4d\u7f6e\u4e0d\u4f1a\u6539\u53d8\uff0c\u5982\u679c\u6ca1\u6709\u6743\u9650\uff0c\u5c31\u4f1a\u51fa\u73b0\u51cf\u53f7[ - ]<\/p>\n<\/blockquote>\n
\u6bcf\u4e2a\u6587\u4ef6\u7684\u5c5e\u6027\u7531\u5de6\u8fb9\u7b2c\u4e00\u90e8\u5206\u768410\u4e2a\u5b57\u7b26\u6765\u786e\u5b9a\uff08\u5982\u4e0b\u56fe\uff09<\/p>\n
<\/p>\n
\u6743\u9650\u4f4d\u8bf4\u660e<\/h3>\n Linux\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u6743\u9650\u4f4d\u662f9\u4e2a\u6743\u9650\u4f4d\u6765\u63a7\u5236\uff0c\u6bcf\u4e09\u4f4d\u4e3a\u4e00\u7ec4\uff0c\u4ed6\u4eec\u5206\u522b\u662f\u6587\u4ef6\u5c5e\u4e3b\uff08Owner\uff09\u7684\u8bfb\u5199\u6267\u884c\uff0c\u7528\u6237\u7ec4\uff08group\uff09\u7684\u8bfb\u5199\u6267\u884c\u4ee5\u53ca\uff08Other\uff09\u5176\u4ed6\u7528\u6237\u7684\u8bfb\u5199\u6267\u884c\uff1b<\/p>\n
\u6587\u4ef6\u5c5e\u4e3b\uff1a \u8bfbr\u3001 \u5199w\u3001\u6267\u884cx\n\u7528\u6237\u7ec4\uff1a \u8bfbr\u3001 \u5199w\u3001\u6267\u884cx\n\u5176\u4ed6\u7528\u6237\uff1a \u8bfbr\u3001 \u5199w\u3001\u6267\u884cx\n\u5982\u679c\u6743\u9650\u4f4d\u4e0d\u53ef\u8bfb\uff0c\u4e0d\u53ef\u5199\uff0c\u4e0d\u53ef\u6267\u884c\uff0c\u5219\u7528-\u6765\u8868\u793a\u3002<\/code><\/pre>\nLinux\u666e\u901a\u6587\u4ef6\u7684\u8bfb\u3001\u5199\u3001\u6267\u884c\u6743\u9650\u8bf4\u660e\uff1a<\/p>\n
\u53ef\u8bfbr\uff1a\u8868\u793a\u5177\u6709\u8bfb\u53d6\u9605\u8bfb\u6587\u4ef6\u5185\u5bb9\u7684\u6743\u9650\n\u53ef\u5199w\uff1a\u8868\u793a\u5177\u6709\u65b0\u589e\u3001\u4fee\u6539\u6587\u4ef6\u5185\u5bb9\u7684\u6743\u9650\uff1b#\uff08\u7279\u522b\u63d0\u9192\uff1a\u5220\u9664\u6216\u4fee\u6539\u3001\u79fb\u52a8\u6587\u4ef6\uff0c\u8fd9\u6837\u7684\u6743\u9650\u53d7\u7236\u76ee\u5f55\u7684\u6743\u9650\u63a7\u5236\uff09\n\u53ef\u6267\u884cx\uff1a\u8868\u793a\u5177\u6709\u6267\u884c\u6587\u4ef6\u7684\u6743\u9650<\/code><\/pre>\nLinux\u76ee\u5f55\u7684\u8bfb\u3001\u5199\u3001\u6267\u884c\u6743\u9650\u8bf4\u660e\uff1a<\/p>\n
\u8fdb\u5165\u76ee\u5f55\u7684\u6743\u9650\uff1ax\n\u6d4f\u89c8\u76ee\u5f55\u7684\u6743\u9650\uff1ar\n\u4fee\u6539\u76ee\u5f55\u5185\u6587\u4ef6\u7684\u6743\u9650\uff1aw<\/code><\/pre>\nLinux\u6587\u4ef6\u4e0e\u76ee\u5f55\u6743\u9650\u5bf9\u6bd4\u8bf4\u660e<\/p>\n
r\uff08read\uff0c\u8bfb\u53d6\u6743\u9650\uff09\uff1a\n\u5bf9\u6587\u4ef6\u800c\u8a00\uff0c\u8868\u793a\u5177\u6709\u8bfb\u53d6\u9605\u8bfb\u6587\u4ef6\u5185\u5bb9\u7684\u6743\u9650\uff1b\n\u5bf9\u76ee\u5f55\u800c\u8a00\uff0c\u8868\u793a\u5177\u6709\u6d4f\u89c8\u76ee\u5f55\u7684\u6743\u9650\uff08\u6ce8\u610f\uff1a\u4e0e\u8fdb\u5165\u76ee\u5f55\u7684\u6743\u9650\u4e0d\u540c\uff09\n\nw\uff08write\uff0c\u5199\u5165\u6743\u9650\uff09:\n\u5bf9\u6587\u4ef6\u800c\u8a00\uff0c\u8868\u793a\u5177\u6709\u65b0\u589e\u3001\u4fee\u6539\u6587\u4ef6\u5185\u5bb9\u7684\u6743\u9650(\u6ce8\u610f\uff1a\u5220\u9664\u548c\u79fb\u52a8\u6587\u4ef6\u548c\u6587\u4ef6\u672c\u8eab\u5c5e\u6027\u65e0\u5173)\uff1b\n\u5bf9\u76ee\u5f55\u800c\u8a00\uff0c\u8868\u793a\u5177\u6709\u5220\u9664\u3001\u4e00\u5b9a\u76ee\u5f55\u5185\u7684\u6743\u9650\n\nx\uff08Execute\uff0c\u6267\u884c\u6743\u9650\uff09\uff1a\n\u5bf9\u6587\u4ef6\u800c\u8a00\uff0c\u8868\u793a\u5177\u6709\u6267\u884c\u6587\u4ef6\u7684\u6743\u9650\uff1b\n\u5bf9\u76ee\u5f55\u800c\u8a00\uff0c\u8868\u793a\u5177\u6709\u8fdb\u5165\u76ee\u5f55\u7684\u6743\u9650\n\n-\uff08\u65e0\u4efb\u4f55\u6743\u9650\uff09\n\u82e5\u5bf9\u5e94\u4f4d\u7f6e\u6743\u9650\u4e3a\u5b57\u7b26\u201d-\u201d\uff0c\u8868\u793a\u5bf9\u5e94\u7528\u6237\u6ca1\u6709\u8bfb\u3001\u5199\u3001\u6267\u884c\u7684\u4efb\u4f55\u6743\u9650\u3002<\/code><\/pre>\n\u7279\u522b\u6ce8\u610f\uff1a<\/p>\n
\u5f53\u5220\u9664\u6216\u79fb\u52a8\u4e00\u4e2a\u6587\u4ef6\u6216\u76ee\u5f55\uff0c\u4ec5\u4e0e\u8be5\u6587\u4ef6\u4e0e\u76ee\u5f55\u6240\u5728\u7684\u4e0a\u4e00\u5c42\u6743\u9650\u6709\u5173\uff0c\u4e0e\u8be5\u6587\u4ef6\u672c\u8eab\u5c5e\u6027\u65e0\u4efb\u4f55\u5173\u7cfb\u3002\n\u5bf9\u4e8e\u6587\u4ef6\u6765\u8bf4\uff0c\u5199\u6587\u4ef6\u662f\u4fee\u6539\u6587\u4ef6\uff0c\u800c\u4e0d\u662f\u5220\u9664\u6587\u4ef6\uff0c\u56e0\u6b64\u5199\u6587\u4ef6\u662f\u4e0e\u8be5\u6587\u4ef6\u7684\u672c\u8eab\u5c5e\u6027\u6709\u5173\u7cfb\u7684\u3002<\/code><\/pre>\n\u6539\u53d8\u6743\u9650\u5c5e\u6027\u547d\u4ee4chmod<\/h3>\n \n chmod\u662f\u7528\u6765\u6539\u53d8\u6587\u4ef6\u6216\u76ee\u5f55\u6743\u9650\u7684\u547d\u4ee4\uff0c\u4f46\u53ea\u6709\u6587\u4ef6\u7684\u5c5e\u4e3b\u548c\u8d85\u7ea7\u7528\u6237root\u624d\u6709\u8fd9\u79cd\u6743\u9650\u3002\u901a\u8fc7chmod\u6765\u6539\u53d8\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u6743\u9650\u6709\u4e24\u79cd\u65b9\u6cd5\uff1a\u4e00\u79cd\u662f\u901a\u8fc7\u6743\u9650\u5b57\u6bcd\u548c\u64cd\u4f5c\u7b26\u8868\u8fbe\u5f0f\u7684\u65b9\u6cd5\u6765\u8bbe\u7f6e\u6743\u9650\uff1b\u53e6\u4e00\u79cd\u662f\u4f7f\u7528\u6570\u5b57\u6765\u8bbe\u7f6e\u6743\u9650\u3002\u4e0b\u9762\u5206\u522b\u8fdb\u884c\u4ecb\u7ecd\u3002<\/p>\n
[root@localhost oldboy]# touch ett.txt #\u521b\u5efaett.txt\u6587\u4ef6 \n[root@localhost oldboy]# touch oldboy.txt #\u521b\u5efaoldboy.txt\u6587\u4ef6\n[root@localhost oldboy]# ls -lh ett.txt oldboy.txt #\u67e5\u770bett.txt\u548coldboy.txt\u6587\u4ef6\u5c5e\u6027 \n-rw-r--r-- 1 root root 0 May 1 10:10 ett.txt\n-rw-r--r-- 1 root root 0 May 1 10:10 oldboy.txt\n[root@localhost oldboy]# chmod 755 ett.txt #\u901a\u8fc7\u6570\u5b57\u6765\u6539\u53d8ett.txt\u7684\u6743\u9650\n[root@localhost oldboy]# chmod u+x,og+x oldboy.txt #\u901a\u8fc7\u5b57\u7b26\u5f0f\u8bed\u6cd5\u6765\u6539\u53d8\u6587\u4ef6\u7684\u6743\u9650\n[root@localhost oldboy]# ls -lh ett.txt oldboy.txt \n-rwxr-xr-x 1 root root 0 May 1 10:10 ett.txt\n-rwxr-xr-x 1 root root 0 May 1 10:10 oldboy.txt<\/code><\/pre>\n\u4e0a\u9762\u662f\u901a\u8fc7chmod\u7684\u4e24\u79cd\u8bed\u6cd5\u6765\u6539\u53d8\u6743\u9650\u7684\u4f8b\u5b50\uff0c\u867d\u7136\u4e24\u79cd\u8bed\u6cd5\u4e0d\u540c\uff0c\u4f46\u662f\u90fd\u80fd\u8fbe\u5230\u540c\u4e00\u76ee\u7684\u3002<\/p>\n
\u8fd9\u4e2a\u8fc7\u7a0b\u662f\uff1a<\/p>\n
1.\u521b\u5efaett.txt\u548coldboy.txt\u4e24\u4e2a\u6587\u4ef6\uff1b\n2.\u67e5\u770b\u4e24\u4e2a\u6587\u4ef6\u7684\u5c5e\u6027\uff1b\u5b83\u4eec\u7684\u6743\u9650\u90fd\u662f\u4e00\u6837\u7684\uff0c\u90fd\u662frw-r--r-- \uff0c\u8868\u793a\u6587\u4ef6\u53ef\u8bfb\u53ef\u5199\u3001\u6587\u4ef6\u6240\u5f52\u5c5e\u7684\u7528\u6237\u7ec4\u5bf9\u6587\u4ef6\u53ef\u8bfb\u3001\u5176\u4ed6\u7528\u6237\u53ef\u8bfb\uff1b\n3.\u901a\u8fc7chmod\u7684\u6570\u5b57\u65b9\u6cd5\u6765\u6539\u53d8ett.txt\u7684\u6743\u9650\uff1b\u901a\u8fc7chmod\u7684\u5b57\u7b26\u5f0f\u8bed\u6cd5\u6765\u6539\u53d8oldboy.txt\u7684\u6743\u9650\uff1b\u6211\u4eec\u7528\u4e24\u79cd\u65b9\u6cd5\u6765\u5206\u522b\u6539\u53d8ett.txt \u548coldboy.txt\u6587\u4ef6\uff0c\u901a\u8fc7chmod\u7684\u4e24\u79cd\u4e0d\u540c\u7684\u8bed\u6cd5\u6765\u8ba9\u4e24\u4e2a\u6587\u4ef6\u7684\u6743\u9650\u8fbe\u5230\u4e00\u81f4\uff1b<\/code><\/pre>\n\u5728\u6570\u5b57\u65b9\u6cd5\u4e2d\uff0c\u6211\u4eec\u7528\u4e86755\uff0c\u800c\u5728\u5b57\u7b26\u5f0f\u8bed\u6cd5\u4e2d\uff0c\u6211\u4eec\u7528\u4e86u+x,og+x\u3002\u867d\u7136\u7528\u4e86\u4e24\u79cd\u4e0d\u540c\u7684\u8bed\u6cd5\uff0c\u4f46\u8fbe\u5230\u4e86\u76f8\u540c\u7684\u76ee\u7684\u3002\u6700\u540e\u7684\u7ed3\u679c\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u4e24\u4e2a\u6587\u4ef6\u7684\u6743\u9650\uff0c\u90fd\u662frwxr-xr-x\u3002\u4e5f\u5c31\u662f\u8bf4\u6587\u4ef6\u7684\u5c5e\u4e3b\u5bf9\u6587\u4ef6\u6709\u53ef\u8bfb\u3001\u53ef\u5199\u3001\u53ef\u6267\u884c\u7684\u6743\u9650\uff0c\u6587\u4ef6\u6240\u5f52\u5c5e\u7684\u7528\u6237\u7ec4\u6709\u53ef\u8bfb\u3001\u53ef\u6267\u884c\u7684\u6743\u9650\uff0c\u5176\u4ed6\u7528\u6237\u6709\u53ef\u8bfb\u3001\u53ef\u6267\u884c\u7684\u6743\u9650\u3002<\/p>\n
\u901a\u8fc7\u4e0a\u9762\u7684\u4f8b\u5b50\uff0c\u8ba9\u6211\u4eec\u7406\u89e3\u4e86chmod\u7684\u4e24\u79cd\u6388\u6743\u8bed\u6cd5\uff1achmod\u7684\u6570\u5b57\u65b9\u6cd5\uff0cchmod\u7684\u5b57\u7b26\u5f0f\u8bed\u6cd5\uff1b\u4e0b\u9762\u6211\u4eec\u5206\u522b\u6765\u53d9\u8ff0\u3002<\/p>\n
chmod\u6570\u5b57\u6743\u9650\u65b9\u6cd5<\/h3>\n \n \u6743\u9650\u7684\u547d\u4ee4\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n
chmod [\u6570\u5b57\u7ec4\u5408] \u6587\u4ef6\u540d<\/code><\/pre>\nChmod\u7684\u6570\u5b57\u8bed\u6cd5\u7b80\u5355\u76f4\u89c2\uff0c\u5728\u88684-1\u4e2d\u5217\u51fa\u4e86\u7528\u6570\u5b57\u8868\u793a\u6743\u9650\u7684\u7ec4\u5408\uff0c\u8be5\u7ec4\u5408\u75313\u4e2a\u516b\u8fdb\u5236\u6570\u6765\u8868\u793a\u6587\u4ef6\u76843\u7c7b\u7528\u6237\u7684\u6743\u9650\u7ec4\u5408\u3002<\/p>\n
chmod\u7684\u6570\u5b57\u65b9\u6cd5\u7684\u8bf4\u660e\uff1b<\/p>\n
r ==> 4 \nw ==> 2\nx ==> 1 \n- ==> 0<\/code><\/pre>\n\u5c5e\u4e3b\u7684\u6570\u5b57\u6743\u9650\u8868\u793a\u6cd5\uff1a<\/strong><\/p>\n\u5c5e\u4e3b\u7684\u6570\u5b57\u6743\u9650\u4e3a\u4e09\u4e2a\u6743\u9650\u4f4d\u7684\u6570\u5b57\u52a0\u8d77\u6765\u7684\u603b\u548c\u3002\u6bd4\u5982\u4e0a\u9762\u7684\u4f8b\u5b50ett.txt\u5c5e\u4e3b\u7684\u6743\u9650\u662frwx\uff0c\u6570\u5b57\u6743\u9650\u4e3a4+2+1=7\uff1b<\/p>\n
\u5c5e\u7ec4\u7684\u6570\u5b57\u6743\u9650\u8868\u793a\u6cd5\uff1a<\/strong><\/p>\n\u5c5e\u7ec4\u7684\u6570\u5b57\u6743\u9650\u540c\u6837\u4e3a\u4e09\u4e2a\u6743\u9650\u4f4d\u7684\u6570\u5b57\u52a0\u8d77\u6765\u7684\u603b\u548c\u3002\u6bd4\u5982\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\u7684r-x\uff0c\u6570\u5b57\u6743\u9650\u4e3a4+0+1=5\uff1b<\/p>\n
\u5176\u4ed6\u7528\u6237\u7684\u6570\u5b57\u6743\u9650\u8868\u793a\u6cd5\uff1a<\/strong><\/p>\n\u5176\u4ed6\u7528\u6237\u6570\u5b57\u6743\u9650\u540c\u6837\u3002\u4e0a\u9762\u4e0a\u9762\u4f8b\u5b50\u4e2d\u662fr-x \uff0c\u6570\u5b57\u6743\u9650\u4e3a4+0+1=5\uff1b<\/p>\n
[root@localhost ~]# cd \/test\/oldboy\/\n[root@localhost oldboy]# ls\nett.txt oldboy oldboy.txt\n[root@localhost oldboy]# ls -l oldboy\n-rwxr-xr-x 1 root root 5 May 1 09:57 oldboy\n[root@localhost oldboy]# chmod 644 oldboy\n[root@localhost oldboy]# ls -l oldboy\n-rw-r--r-- 1 root root 5 May 1 09:57 oldboy<\/code><\/pre>\n\u6bcf\u4e2a\u4e09\u4f4d\u7684\u6743\u9650\u4ee3\u7801\uff08\u5206\u522b\u662f\u5c5e\u4e3b\u3001\u6570\u7ec4\uff0c\u5176\u4ed6\u7528\u6237\uff09\u7ec4\u5408\uff0c\u67098\u79cd\u53ef\u80fd;<\/p>\n
<\/p>\n
<\/p>\n
\u63d0\u793a\uff1a\u6211\u4eec\u6839\u636e\u4e0a\u9762\u7684\u6570\u5b57\u5217\u8868\u6765\u7ec4\u5408\u6743\u9650\uff0c\u6bd4\u5982\u6211\u60f3\u8ba9\u5c5e\u4e3b\u62e5\u6709rwx\uff08\u6240\u5bf9\u5e94\u7684\u6570\u5b57\u662f7\uff09\uff0c\u6570\u7ec4\u62e5\u6709-x\uff08\u6240\u5bf9\u5e94\u7684\u6570\u5b57\u662f1\uff09\uff0c\u5176\u4ed6\u7528\u6237\u62e5\u6709--\uff08\u6240\u5bf9\u5e94\u7684\u6570\u5b57\u662f0\uff09\uff0c\u8fd9\u6837\u6211\u4eec\u628a\u5404\u7ec4\u7684\u6743\u9650\u7ec4\u5408\u5c31\u662frwx--x---\uff08\u5bf9\u4e8e\u7684\u6570\u5b57\u662f710\uff09<\/p>\n
[root@localhost oldboy]# ls -l oldboy\n-rw-r--r-- 1 root root 5 May 1 09:57 oldboy \n[root@localhost oldboy]# chmod 710 oldboy\n[root@localhost oldboy]# ls -l oldboy\n-rwx--x--- 1 root root 5 May 1 09:57 oldboy<\/code><\/pre>\n\u5982\u679c\u6211\u4eec\u60f3\u6539\u53d8\u7684\u4ec5\u4ec5\u662f\u6253\u5f00\u76ee\u5f55\u7684\u6743\u9650\uff0c\u4f7f\u7528chmod\u547d\u4ee4\u65f6\u4e0d\u7528\u52a0\u4efb\u4f55\u53c2\u6570\u3002\u5982\u679c\u60f3\u628a\u76ee\u5f55\u4e00\u4e0b\u554a\u7684\u6240\u6709\u6587\u4ef6\u6216\u5b50\u76ee\u5f55\u4e5f\u540c\u65f6\u6539\u53d8\uff0c\u9700\u8981\u4f7f\u7528-R\u53c2\u6570\uff1b<\/p>\n
[root@localhost oldboy]# mkdir etiantian\n[root@localhost oldboy]# touch ett_oldboy\n[root@localhost oldboy]# mv ett_oldboy etiantian\/\n[root@localhost oldboy]# ls -ld etiantian\/ #\u6211\u4eec\u67e5\u770b\u5230\u7684etiantian\u76ee\u5f55\u7684\u6743\u9650\u662frwxr-xr-x\uff1b\ndrwxr-xr-x 2 root root 4096 May 1 21:35 etiantian\/<\/code><\/pre>\n\u6211\u4eec\u4ec5\u4ec5\u6539\u53d8etiantian\u7684\u6743\u9650\uff0c\u8ba9\u5176\u62e5\u6709\u5c5e\u4e3b\u53ef\u8bfb\u53ef\u5199\u3001\u5c5e\u7ec4\u53ef\u8bfb\u3001\u5176\u4ed6\u7528\u6237\u53ef\u8bfb\uff0c\u4e5f\u5c31\u662frw-r--r--\uff0c\u7528\u6570\u5b57\u6743\u9650\u8868\u793a\u4e3a644.<\/p>\n
[root@localhost oldboy]# chmod 644 etiantian\/\n[root@localhost oldboy]# ls -ld etiantian\/ \ndrw-r--r-- 2 root root 4096 May 1 21:35 etiantian\/ #\u6539\u53d8\u6210\u529f\n[root@localhost oldboy]# ls -lr etiantian\/ #\u6211\u4eec\u67e5\u770b\u4e00\u4e0betiantian\u76ee\u5f55\u4e0b\u7684\u5b50\u76ee\u5f55\u662f\u5426\u6539\u53d8\u4e86\uff1f \ntotal 4\n-rw-r--r-- 1 root root 0 May 1 21:34 ett_oldboy <\/code><\/pre>\n\u5c1d\u8bd5\u4e00\u4e0b\u628aetiantian\u53ca\u5176\u5b50\u76ee\u5f55\u548c\u6587\u4ef6\u6743\u9650\u90fd\u8981\u6539\u53d8\u4e3arw-r--r-- \u6743\u9650\u3002\u6211\u4eec\u8981\u7528\u5230-R\u53c2\u6570\uff1b<\/p>\n
oot@localhost oldboy]# chmod -R 644 etiantian\/ #\u6211\u4eec\u6539\u53d8etiantian\u4e0b\u6240\u6709\u7684\u6587\u4ef6\u6216\u5b50\u76ee\u5f55\u7684\u6743\u9650\u90fd\u4e3arw-r--r-- \uff1b\n[root@localhost oldboy]# ls -ld etiantian\/\ndrw-r--r-- 2 root root 4096 May 1 21:35 etiantian\/\n[root@localhost oldboy]# ls -lr etiantian\/\ntotal 4\n-rw-r--r-- 1 root root 0 May 1 21:34 ett_oldboy<\/code><\/pre>\n\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff1achmod\u6539\u53d8\u4e00\u4e2a\u76ee\u5f55\u4e0b\u7684\u6240\u6709file\u65f6\uff0c\u8981\u5c0f\u5fc3\u64cd\u4f5c\u3002\u6bd4\u5982\u6211\u4eec\u8981\u6539\u53d8etiantian\u4e0b\u7684\u6240\u6709file\u7684\u6743\u9650\u4e3arwxr--r-- \uff0c\u4f46\u6211\u4eec\u4e0d\u60f3\u6539\u53d8etiantian\u76ee\u5f55\u7684\u6743\u9650\u3002\u4e0b\u9762\u7684\u4f8b\u5b50\u64cd\u4f5c\u662f\u9519\u8bef\u7684\u3002<\/p>\n
[root@localhost oldboy]# ls -ld etiantian\/\ndrw-r--r-- 2 root root 4096 May 1 21:35 etiantian\/\n[root@localhost oldboy]# ls -lr etiantian\/\ntotal 4\n-rw-r--r-- 1 root root 0 May 1 21:34 ett_oldboy\n[root@localhost oldboy]# chmod -R 755 etiantian\/* #\u8fd9\u6837\u64cd\u4f5c\uff0c\u4f1a\u628aetiantian\u76ee\u5f55\u7684\u6743\u9650\u4e00\u5e76\u6539\u4e3arwxr--r-- ;\n[root@localhost oldboy]# ls -ld etiantian\/\ndrwxr-xr-x 2 root root 4096 May 1 21:35 etiantian\/<\/code><\/pre>\n\u6240\u4ee5\u5f53\u4f60\u60f3\u6539\u53d8\u4e00\u4e2a\u76ee\u5f55\u4e0b\u7684\u6240\u6709.file\u6743\u9650\uff0c\u5e76\u4e14\u60f3\u4fdd\u7559\u8be5\u76ee\u5f55\u7684\u539f\u6709\u6743\u9650\u65f6\uff0c\u8bf7\u4e0d\u8981\u7528.*\u901a\u914d\u7b26\u3002\u53ef\u7528\u4e0b\u9762\u7684\u5339\u914d\uff1a<\/p>\n
[root@localhost oldboy]# chmod -R 644 etiantian\/[a-z]*<\/code><\/pre>\n\u4e0a\u9762\u7684\u4f8b\u5b50chmod\u4f1a\u5339\u914d\u6240\u6709\u4ee5a\u5230z\u5f00\u5934\u7684\u6587\u4ef6<\/p>\n
chmod\u5b57\u7b26\u5f0f\u6743\u9650\u8868\u793a\u6cd5<\/h3>\n \n \u4f7f\u7528\u6743\u9650\u5b57\u7b26\u8bbe\u7f6e\u6743\u9650\u7684\u547d\u4ee4\u683c\u5f0f\u4ee5\u4e0b\uff1a<\/p>\n
chmod [\u7528\u6237\u7c7b\u578b] [+|-|=] [\u6743\u9650\u5b57\u7b26] \u6587\u4ef6\u540d<\/code><\/pre>\nchmod\u7684\u5b57\u7b26\u5f0f\u8bed\u6cd5\u76f8\u5bf9\u7b80\u5355\uff0c\u5bf9\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u6539\u53d8\u65f6\uff0c\u662f\u901a\u8fc7\u6bd4\u8f83\u76f4\u89c2\u7684\u5b57\u7b26\u7684\u5f62\u5f0f\u6765\u5b8c\u6210\uff1b<\/p>\n
\u5728\u5b57\u7b26\u5f0f\u8bed\u6cd5\u4e2d\uff0c\u76f8\u5173\u5b57\u6bcd\u7684\u5b9a\u4e49\uff1b<\/p>\n
\u7528\u6237\u6216\u7528\u6237\u7ec4\u5b9a\u4e49\uff1a\n\nu\uff1a\u4ee3\u8868\u5c5e\u4e3b\n\ng:\u4ee3\u8868\u5c5e\u7ec4\n\no:\u4ee3\u8868\u5176\u4ed6\u7528\u6237\n\na:\u4ee3\u8868\u5c5e\u4e3b\u3001\u5c5e\u7ec4\u548c\u5176\u4ed6\u7528\u6237\uff0c\u4e5f\u5c31\u662f\u4e0a\u9762\u4e09\u4e2a\u7528\u6237\uff08\u6216\u7ec4\uff09\u7684\u6240\u6709\uff1b<\/code><\/pre>\n\u6743\u9650\u5b9a\u4e49\u5b57\u6bcd\uff1a<\/p>\n
r \u4ee3\u8868\u8bfb\u6743\u9650 \nw \u4ee3\u8868\u5199\u6743\u9650\nx \u4ee3\u8868\u6267\u884c\u6743\u9650<\/code><\/pre>\n\u6743\u9650\u589e\u51cf\u5b57\u7b26<\/p>\n
+\uff1a\u6dfb\u52a0\u67d0\u4e2a\u6743\u9650\n-\uff1a\u53d6\u6d88\u67d0\u4e2a\u6743\u9650\n=\uff1a \u8d4b\u4e88\u7ed9\u5b9a\u6743\u9650\u5e76\u53d6\u6d88\u5176\u4ed6\u6240\u6709\u6743\u9650<\/code><\/pre>\n\u793a\u4f8b1\uff1a<\/p>\n
[root@localhost oldboy]# ls -l ett.txt \n-rwxr-xr-x 1 root root 0 May 1 10:10 ett.txt\n[root@localhost oldboy]# chmod ugo-x ett.txt #\u628a\u5c5e\u4e3b\u3001\u7528\u6237\u7ec4\u53ca\u5176\u4ed6\u7528\u6237\u7684\u6267\u884c\u6743\u9650\u90fd\u51cf\u6389\n[root@localhost oldboy]# ls -l ett.txt\n-rw-r--r-- 1 root root 0 May 1 10:10 ett.txt #\u6211\u4eec\u770b\u5230\u5bf9\u4e8e\u6743\u9650\u7684x\u4f4d\u5df2\u7ecf\u53d8\u6210\u4e86-\u53f7<\/code><\/pre>\n\u793a\u4f8b2\uff1a<\/p>\n
[root@localhost oldboy]# ls -l ett.txt\n-rw-r--r-- 1 root root 0 May 1 10:10 ett.txt\n[root@localhost oldboy]# chmod u+x ett.txt #\u4e3a\u6587\u4ef6\u7684\u5c5e\u4e3b\u589e\u52a0\u6267\u884c\u6743\u9650\n[root@localhost oldboy]# ls -l ett.txt\n-rwxr--r-- 1 root root 0 May 1 10:10 ett.txt #\u6211\u4eec\u770b\u5230x\u4f4d\u5df2\u7ecf\u53d8\u6210\u4e86x\u53f7<\/code><\/pre>\n\u793a\u4f8b3\uff1a<\/p>\n
[root@localhost oldboy]# ls -l ett.txt\n-rwxr--r-- 1 root root 0 May 1 10:10 ett.txt\n[root@localhost oldboy]# chmod u-x,go+rw ett.txt #\u51cf\u53bb\u6587\u4ef6\u5c5e\u4e3b\u5bf9\u6587\u4ef6\u7684\u6267\u884c\u6743\uff0c\u589e\u52a0\u5c5e\u7ec4\u548c\u5176\u4ed6\u7528\u6237\u5bf9\u6587\u4ef6\u7684\u53ef\u8bfb\u5199\u6743\uff1b\n[root@localhost oldboy]# ls -l ett.txt\n-rw-rw-rw- 1 root root 0 May 1 10:10 ett.txt<\/code><\/pre>\n\u7528\u5b57\u7b26\u5f0f\u8bed\u6cd5\u6bd4\u8f83\u7075\u6d3b\uff0c\u7ec4\u5408\u8d77\u6765\u65b9\u4fbf\uff1b\u6bd4\u5982\uff1a<\/p>\n
u=r+x \u4e3a\u6587\u4ef6\u5c5e\u4e3b\u6dfb\u52a0\u8bfb\u5199\u6743\u9650\nug=rwx,0=r \u4e3a\u5c5e\u4e3b\u548c\u5c5e\u7ec4\u6dfb\u52a0\u8bfb\u3001\u5199\u3001\u6267\u884c\u6743\u9650\uff0c\u4e3a\u5176\u4ed6\u7528\u6237\u8bbe\u7f6e\u8bfb\u6743\u9650\na+x\uff1a\u4e3a\u6587\u4ef6\u7684\u5c5e\u4e3b\u3001\u5c5e\u7ec4\u548c\u5176\u4ed6\u7528\u6237\u6dfb\u52a0\u6267\u884c\u6743\u9650\ng=u\uff1a\u8ba9\u6587\u4ef6\u7684\u5c5e\u7ec4\u548c\u5c5e\u4e3b\u548c\u6743\u9650\u76f8\u540c\uff1b<\/code><\/pre>\n\u5bf9\u4e8e\u76ee\u5f55\u6743\u9650\u7684\u8bbe\u7f6e\uff0c\u8981\u7528\u5230-R\u53c2\u6570\uff1a<\/strong><\/p>\n\u548c\u6570\u5b57\u6743\u9650\u65b9\u6cd5\u4e00\u6837\uff0c\u5982\u679c\u6211\u4eec\u4f1a\u4e3a\u4e00\u4e2a\u76ee\u5f55\u53ca\u5176\u4e0b\u7684\u5b50\u76ee\u5f55\u548c\u6587\u519b\u5177\u6709\u76f8\u540c\u7684\u5c5e\u6027\uff0c\u5c31\u53ef\u4ee5\u7528-R\u53c2\u6570\uff1b<\/p>\n
[root@localhost oldboy]# chmod -R a+rwx etiantian\/\n[root@localhost oldboy]# ls -lr etiantian\/\ntotal 4\n-rwxrwxrwx 1 root root 0 May 1 21:34 ett_oldboy<\/code><\/pre>\n\u9ed8\u8ba4\u6743\u9650\u5206\u914d\u7684\u547d\u4ee4umask<\/h3>\n umask\u662f\u901a\u8fc7\u516b\u8fdb\u5236\u7684\u6570\u503c\u6765\u5b9a\u4e49\u7528\u6237\u521b\u5efa\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u9ed8\u8ba4\u6743\u9650\u3002umask\u8868\u793a\u7684\u662f\u7981\u6b62\u6743\u9650\u3002\u5177\u4f53\u7684\u7ec6\u8282\uff0c\u6587\u4ef6\u548c\u76ee\u5f55\u7565\u6709\u4e0d\u540c\u3002<\/p>\n
\u91cd\u8981\u603b\u7ed3\uff1a<\/p>\n
\u5bf9\u4e8e\u6587\u4ef6\u6765\u8bf4\uff0cumask\u7684\u8bbe\u7f6e\u662f\u5728\u5047\u5b9a\u6587\u4ef6\u62e5\u6709\u516b\u8fdb\u5236666\u6743\u9650\u4e0a\u8fdb\u884c\uff0c\u6587\u4ef6\u7684\u6743\u9650\u5c31\u662f666\u51cf\u53bbumask\u7684\u63a9\u7801\u6570\u503c\uff1b\n \u5bf9\u4e8e\u76ee\u5f55\u6765\u8bf4\uff0cumask\u7684\u8bbe\u7f6e\u662f\u5728\u5047\u5b9a\u6587\u4ef6\u62e5\u6709\u516b\u8fdb\u5236777\u6743\u9650\u4e0a\u8fdb\u884c\uff0c\u76ee\u5f55\u516b\u8fdb\u5236\u6743\u9650777\u51cf\u53bbumask\u7684\u63a9\u7801\u6570\u503c\uff1b<\/code><\/pre>\n\u9ed8\u8ba4\u6587\u4ef6\u6743\u9650\u8ba1\u7b97\u65b9\u6cd5<\/strong><\/p>\n666 ==> \u6587\u4ef6\u7684\u8d77\u59cb\u6743\u9650\u503c\n022- ==> umask\u7684\u503c\n.............\n644<\/code><\/pre>\n\u9ed8\u8ba4\u76ee\u5f55\u6743\u9650\u8ba1\u7b97\u65b9\u6cd5<\/strong><\/p>\n777 ==>\u76ee\u5f55\u7684\u8d77\u59cb\u6743\u9650\u503c\n022- ==>umask\u7684\u503c\n.............\n755<\/code><\/pre>\n\u793a\u4f8b1\uff1a<\/p>\n
[root@localhost oldboy]# umask\n0022 #umask\u5f53\u524d\u6570\u503c\n[root@localhost oldboy]# umask 044 #\u66f4\u6539\u4e3a044\n[root@localhost oldboy]# umask\n0044\n[root@localhost oldboy]# mkdir umask_test #\u5efa\u76ee\u5f55\u6d4b\u8bd5\n[root@localhost oldboy]# ls -ld umask_test\/\ndrwx-wx-wx 2 root root 4096 May 1 23:32 umask_test\/ #\u5bf9\u4e8e\u6570\u5b57\u6743\u9650\u4e3a733\uff0c\u662f\u4e0d\u662f\u670d\u52a1\u4e0a\u9762\u7684\u8ba1\u7b97\u65b9\u6cd5\uff1f\n[root@localhost oldboy]# touch umask_test.txt\n[root@localhost oldboy]# ls -l umask_test.txt \n-rw--w--w- 1 root root 0 May 1 23:32 umask_test.txt #\u5bf9\u4e8e\u6570\u5b57\u6743\u9650\u4e3a622\uff0c\u662f\u4e0d\u662f\u670d\u52a1\u4e0a\u9762\u7684\u8ba1\u7b97\u65b9\u6cd5\uff1f<\/code><\/pre>\n\u793a\u4f8b2\uff1a<\/p>\n
Linux\u7cfb\u7edf\u7528\u6237\u7684\u5bb6\u76ee\u5f55\u7684\u6743\u9650\u662f\u901a\u8fc7\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u6307\u5b9a\u7684\uff0c\u6bd4\u5982\/etc\/login.defs\u6587\u4ef6\uff1b<\/p>\n
\u5176\u4e2d\u6709\u8fd9\u6837\u4e00\u6bb5\uff1a<\/p>\n
# If useradd should create home directories for users by default\n# On RH systems, we do. This option is overridden with the -m flag on\n# useradd command line.\n#\nCREATE_HOME yes\n\n# The permission mask is initialized to this value. If not specified, \n# the permission mask will be initialized to 022.\nUMASK 077<\/code><\/pre>\n\u8868\u793a\u7684\u610f\u601d\u662f\uff0c\u5f53\u6211\u4eec\u521b\u5efa\u7528\u6237\u65f6\uff0c\u4ed6\u7684\u5bb6\u76ee\u5f55umask\u7684\u6570\u503c\u662f077\u3002\u6211\u4eec\u600e\u4e48\u7406\u89e3\u8fd9\u4e2a077\u5462\u3002<\/p>\n
\u5f53\u6dfb\u52a0\u7528\u6237\u65f6\uff0c\u7cfb\u7edf\u81ea\u52a8\u5728\/home\u4e2d\u521b\u5efa\u7528\u6237\u7684\u5bb6\u76ee\u5f55\uff0c\u5e76\u4e14\u8bbe\u7f6e\u5b83\u7684\u6743\u9650\u4e3a777-077=700\uff0c\u4e5f\u5c31\u662frwx------\uff0c\u6211\u4eec\u770b\u4e00\u4e0b\/home\u4e0b\u7684\u67d0\u4e2a\u7528\u6237\u7684\u5bb6\u76ee\u5f55\u662f\u4e0d\u662f\u8fd9\u6837\u7684\u5462\uff1f<\/p>\n
[root@localhost oldboy]# ls -ld \/home\/zgy\/\ndrwx------ 3 zgy zgy 4096 Apr 30 21:40 \/home\/zgy\/<\/code><\/pre>\nUmask\u4e00\u822c\u90fd\u662f\u653e\u5728\u7528\u6237\u76f8\u5173SHELL\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u6bd4\u5982\u7528\u6237\u5bb6\u76ee\u5f55\u4e0b\u7684.bashrc\u6216.profile\uff0c\u4e5f\u53ef\u4ee5\u653e\u5728\u5168\u5c40\u6027\u7684\u7528\u6237\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u6bd4\u5982\/etc\/login.defs\uff0c\u8fd8\u53ef\u4ee5\u653e\u5728SHELL\u5168\u5c40\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u6bd4\u5982\/etc\/bashrc\u6216\/etc\/profile\u7b49\uff1b<\/p>\n
umask\u653e\u5728\u76f8\u5173\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u76ee\u7684\u662f\u5f53\u7ba1\u7406\u5458\u521b\u5efa\u7528\u6237\u65f6\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u4e3a\u7528\u6237\u521b\u5efa\u6587\u4ef6\u6216\u76ee\u5f55\u65f6\u914d\u7f6e\u9ed8\u8ba4\u7684\u6743\u9650\u4ee3\u7801\u3002<\/p>\n
\u7279\u522b\u63d0\u793a\uff1a\u5728\u4e00\u822c\u751f\u4ea7\u573a\u666f\uff0cumask\u7684\u4f7f\u7528\u4e0d\u591a\u89c1\uff0c\u5728\u6b64\uff0c\u5927\u5bb6\u4e86\u89e3\u4e0bumask\u662f\u600e\u4e48\u56de\u4e8b\u5373\u53ef\u3002<\/p>\n
setid\u548csetgid\u4f4d<\/strong><\/h3>\n\u7279\u522b\u63d0\u9192\uff1a<\/p>\n
\u672c\u90e8\u5206\u5185\u5bb9\u4ec5\u4e3a\u4e86\u89e3\u5185\u5bb9\uff0c\u5728\u4e00\u822c\u7684\u751f\u4ea7\u573a\u666f\uff0c\u8fd0\u7ef4\u4eba\u5458\u4f7f\u7528\u8272\u63a8\u52a8\uff0csetgid\u7684\u60c5\u51b5\u4e0d\u591a\u89c1\uff0c\u4e5f\u4e0d\u63a8\u8350\u5927\u5bb6\u4f7f\u7528<setuid\uff0csetgid\u672c\u8eab\u529f\u80fd\u4e0d\u9519\uff0c\u4f46\u662f\u4f1a\u5e26\u6765\u5b89\u5168\u9690\u60a3>\u3002\u5728\u6b64\uff0c\u5927\u5bb6\u4e86\u89e3\u4e0bsetuid\uff0csetgid\u662f\u600e\u4e48\u56de\u4e8b\u5373\u53ef\u3002<\/p>\n
setuid\u548csetgid\u4ecb\u7ecd<\/h3>\n setuid\u548csetgid\u4f4d\u662f\u8ba9\u666e\u901a\u7528\u6237\u53ef\u4ee5\u8ba9root\u7528\u6237\u7684\u89d2\u8272\u8fd0\u884c\u53ea\u6709root\u8d26\u53f7\u624d\u80fd\u8fd0\u884c\u7684\u7a0b\u5e8f\u6216\u547d\u4ee4\u3002\uff08\u6ce8\u610f\u548csu\u53casudo\u7684\u533a\u522b\uff09<\/p>\n
\u5728Linux\u4e2d\uff0c\u6709\u65f6\u6267\u884c\u67d0\u4e2a\u547d\u4ee4\u65f6\uff0c\u9700\u8981\u5bf9\u53e6\u4e00\u4e2a\u6587\u4ef6\u8fdb\u884c\u64cd\u4f5c\uff0c\u800c\u8fd9\u4e2a\u6587\u4ef6\u53c8\u4e0d\u662f\u666e\u901a\u7528\u6237\u6709\u6743\u9650\u8fdb\u884c\u64cd\u4f5c\u7684\u3002\u4f8b\u5982\uff0c\u4fee\u6539\u7528\u6237\u5bc6\u7801\u7684\u547d\u4ee4passwd\uff0c\u5b9e\u9645\u4e0a\u6700\u7ec8\u66f4\u6539\u7684\u662f\/etc\/passwd\u6587\u4ef6\uff0c\u8be5\u6587\u4ef6\u7684\u6240\u6709\u8005\u548c\u7ec4\u90fd\u662froot\uff0c\u540c\u7ec4\u7528\u6237\u548c\u5176\u4ed6\u7528\u6237\u5177\u6709\u6267\u884c\u6743\u9650\uff0c\u53ea\u6709root\u6743\u9650\u7684\u7528\u6237\u624d\u80fd\u66f4\u6539\uff0c\u4f46\u662f\u666e\u901a\u7528\u6237\u4e5f\u53ef\u4f7f\u7528\u8be5\u547d\u4ee4\u4fee\u6539\u81ea\u5df1\u5bc6\u7801\uff08\u8fd9\u4e2a\u4e0d\u7528\u9a8c\u8bc1\u4e86\u5427\uff1f\uff09<\/p>\n
[root@localhost oldboy]# ls -l \/etc\/passwd\n-rw-r--r-- 1 root root 1496 Apr 30 21:40 \/etc\/passwd <\/code><\/pre>\n#\u6240\u6709\u8005\u548c\u7ec4\u90fd\u662froot\uff0c\u6309\u7167\u6211\u4eec\u5b66\u8fc7\u7684\u77e5\u8bc6\uff0c\u666e\u901a\u7528\u6237\u662f\u65e0\u6cd5\u66f4\u6539\u8fd9\u4e2a\u6587\u4ef6\u7684\uff0c\u4f46\u662fsetuid\u7684\u529f\u80fd\u53ef\u4ee5\u8ba9\u666e\u901a\u7528\u6237\u505a\u5230\u8fd9\u4e2a\u672c\u6ca1\u6709\u6743\u9650\u7684\u5bc6\u7801\u6587\u4ef6<\/p>\n
\u6309\u7167\u6211\u4eec\u5b66\u8fc7\u7684\u77e5\u8bc6\uff0c\u5982\u679c\u666e\u901a\u7528\u6237\u901a\u8fc7\u4fee\u6539\/etc\/passwd\u4fee\u6539\u81ea\u5df1\u7684\u53e3\u4ee4\u80af\u5b9a\u662f\u4e0d\u53ef\u5b8c\u6210\u7684\u4efb\u52a1\u3002\u5e73\u65f6\u6211\u4eec\u4e5f\u4e0d\u8fd9\u4e48\u505a\uff0c\u4f5c\u4e3a\u666e\u901a\u7528\u6237\u53ef\u4ee5\u901a\u8fc7passwd\u6765\u4fee\u6539\u81ea\u5df1\u7684\u53e3\u4ee4\uff0c\u65e2\u7136\u6ca1\u6743\u9650\uff0c\u4e3a\u4ec0\u4e48\u8fd8\u80fd\u4fee\u6539\u5bc6\u7801\u5462\uff1f\u5728\u7b54\u6848\u63ed\u6653\u524d\uff0c\u6211\u4eec\u6765\u770b\u4e00\u4e0bpasswd\u547d\u4ee4\u7684\u6743\u9650\u3002<\/p>\n
[root@localhost oldboy]# ls -l \/usr\/bin\/passwd \n-rwsr-xr-x 1 root root 23420 Aug 3 2010 \/usr\/bin\/passwd<\/code><\/pre>\n\u56e0\u4e3a\/usr\/bin\/passwd\u6587\u4ef6\u5df2\u7ecf\u8bbe\u7f6e\u4e86setuid\u6743\u9650\u4f4d\uff08\u4e5f\u5c31\u662fr-s--x--x\u4e2d\u7684s\uff09\uff0c\u6240\u4ee5\u666e\u901a\u7528\u6237\u5728\u6267\u884c\/usr\/bin\/passwd\u547d\u4ee4\u65f6\u80fd\u591f\u4f7f\u7528root\u7528\u6237\u7684\u6743\u9650\uff0c\u95f4\u63a5\u7684\u4fee\u6539\/etc\/passwd\uff0c\u5df2\u8fbe\u5230\u4fee\u6539\u81ea\u5df1\u53e3\u4ee4\u7684\u6743\u9650\u3002<\/p>\n
\u6211\u4eec\u77e5\u9053Linux\u7684\u7528\u6237\u7ba1\u7406\u662f\u6781\u4e3a\u4e25\u683c\u7684\uff0c\u4e0d\u540c\u7684\u7528\u6237\u62e5\u6709\u4e0d\u540c\u7684\u6743\u9650\uff0c\u4e3a\u4e86\u5b8c\u6210\u53ea\u6709root\u7528\u6237\u624d\u80fd\u5b8c\u6210\u7684\u5de5\u4f5c\uff0c\u6211\u4eec\u5fc5\u987b\u4e3a\u666e\u901a\u7528\u6237\u63d0\u5347\u6743\u9650\uff0c\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u5c31\u662fsu\u6216sudo\u3002\u4e3a\u4e86setuid\u548csetgid\u4e5f\u662f\u8ba9\u666e\u901a\u7528\u6237\u8d85\u8d8a\u81ea\u8eab\u62e5\u6709\u7684\u666e\u901a\u6743\u9650\u8fbe\u5230\u4f7f\u7528root\u6743\u9650\u7684\u65b9\u6cd5\u3002\u4f46\u4e0d\u63a8\u8350\u5927\u5bb6\u4f7f\u7528\uff0c\u56e0\u4e3a\u5b83\u80fd\u4e3a\u7cfb\u7edf\u5e26\u6765\u5b89\u5168\u9690\u60a3\uff01\uff01<\/p>\n
\u7279\u522b\u63d0\u9192\uff1asetuid\u548csetgid\u4f1a\u9762\u4e34\u98ce\u9669\uff0c\u6240\u4ee5\u5c3d\u53ef\u80fd\u7684\u5c11\u7528\uff08\u5c24\u5176\u662f\u4f7f\u7528\u4e0d\u5f53\uff09\uff0c\u4e86\u89e3\u4ec0\u4e48\u56de\u4e8b\u5373\u53ef\u3002<\/p>\n
setuid\u548csetgid\u5b9e\u4f8b\u5e94\u7528<\/strong><\/h3>\n\u6211\u4eec\u60f3\u8ba9\u4e00\u4e2a\u666e\u901a\u7528\u6237oldboy\u62e5\u6709root\u7528\u6237\u624d\u62e5\u6709\u7684rm\u5220\u9664\u6743\u9650\uff0c\u6211\u4e48\u9664\u4e86\u7528su\u6216sudo\u4e34\u65f6\u5207\u6362\u5230root\u8eab\u4efd\u6216\u4ee5root\u7684\u8eab\u4efd\u64cd\u4f5c\u610f\u5916\uff0c\u8fd8\u53ef\u4ee5\u600e\u4e48\u505a\u5462\uff1f<\/p>\n
[root@localhost oldboy]# cd \/home\/ #\u8fdb\u5165\/home\u76ee\u5f55\n[root@localhost home]# touch zgytest.txt #\u521b\u5efa\u4e00\u4e2a\u6d4b\u8bd5\u6587\u4ef6\n[root@localhost home]# ls -l zgytest.txt #\u67e5\u770b\u6587\u4ef6\u5c5e\u6027\n-rw--w--w- 1 root root 0 May 2 01:04 zgytest.txt #\u6587\u4ef6\u7684\u5c5e\u6027\n[root@localhost home]# su - zgy #\u5207\u6362\u666e\u901a\u7528\u6237\n[zgy@localhost ~]$ cd \/home\/ \n[zgy@localhost home]$ rm -f zgytest.txt #\u4ee5\u666e\u901a\u7528\u6237\u8eab\u4efd\u6765\u5220\u9664zgytest.txt\u6587\u4ef6\nrm: cannot remove `zgytest.txt': Permission denied #\u6743\u9650\u4e0d\u591f<\/code><\/pre>\n\u90a3\u6211\u4eec\u600e\u6837\u624d\u80fd\u8ba9zgy\u8fd9\u4e2a\u666e\u901a\u7528\u6237\u4e5f\u62e5\u6709root\u8d85\u7ea7\u7684rm\u5220\u9664\u529f\u529b\u5462\uff1f\u597d\uff0c\u5f15\u51fa\u672c\u8282\u7684\u4e3b\u9898setuid\uff0csetgid\u3002<\/p>\n
[root@localhost ~]# ls -l \/bin\/rm\n-rwxr-xr-x 1 root root 46480 Mar 14 2012 \/bin\/rm\n[root@localhost ~]# chmod 4755 \/bin\/rm #\u8bbe\u7f6erm\u7684\u6743\u9650\u4e3a4755\uff0c\u8fd9\u6837\u5c31\u628asetuid\u4f4d\u8bbe\u7f6e\u597d\u4e86\n[root@localhost ~]# ls -l \/bin\/rm\n-rwsr-xr-x 1 root root 46480 Mar 14 2012 \/bin\/rm #\u5c5e\u4e3b\u4f4d\u7f6e\u589e\u52a0\u4e86s\n[root@localhost ~]# cd \/home\/\n[root@localhost home]# su - zgy #\u5207\u6362\u5230\u666e\u901a\u7528\u6237zgy\n[zgy@localhost ~]$ cd \/home\/\n[zgy@localhost home]$ ls -l zgytest.txt #\u67e5\u770b\u6587\u4ef6\u5c5e\u6027\n-rw--w--w- 1 root root 0 May 2 01:04 zgytest.txt #\u6587\u4ef6\u5c5e\u6027\n[zgy@localhost home]$ rm -f zgytest.txt #\u8f7b\u677e\u7684\u5220\u9664\u4e86zgytest.txt\u6587\u4ef6<\/code><\/pre>\n\u5982\u4e0a\u9762\u5185\u5bb9\u6240\u793a\uff0c\u6211\u4eec\u8bbe\u7f6e\u4e86rm\u7684setuid\u4f4d\u540e\uff0c\u5c31\u8ba9\u666e\u901a\u7528\u6237\u5728rm\u6307\u4ee4\u4e0a\u6709\u4e86\u8d85\u7ea7root\u624d\u80fd\u4eab\u53d7\u7684\u5220\u9664\u6743\u529b\u3002<\/p>\n
\u901a\u8fc7\u8fd9\u4e2a\u4f8b\u5b50\uff0c\u6211\u4eec\u5e94\u8be5\u80fd\u660e\u767dsetuid\u548csetgid\u4f4d\u7684\u5e94\u7528\u4e86\uff0c\u5982\u540c\u524d\u9762\u6240\u8bf4\uff0c\u8ba9\u666e\u901a\u7528\u6237\u8d85\u8d8a\u672c\u8eab\u7684\u80fd\u529b\uff0c\u8ba9\u666e\u901a\u7528\u6237\u80fd\u6267\u884c\u53ea\u6709root\u624d\u80fd\u6267\u884c\u7684\u547d\u4ee4\u3002\u5728\u8fd9\u4e00\u70b9\uff0c\u6211\u4eec\u8981\u548csu\u548csudo\u533a\u5206\u5f00\u6765\u3002<\/p>\n
setuid\u548csetgid\u8bbe\u7f6e\u8bf4\u660e<\/h3>\n \u7279\u6b8a\u6743\u9650\u4f4d\u6570\u5b57\u6743\u9650\uff08\u516b\u8fdb\u5236\uff09\u65b9\u6cd5<\/strong><\/p>\nsetuid\u4f4d\u662f\u7528\u516b\u8fdb\u5236\u76844000\uff0csetgid\u5360\u7528\u7684\u662f\u628a\u60a8\u5728\u76842000\uff1b\u6bd4\u5982\u6211\u4eec\u524d\u9762\u6240\u8bf4\u7684chmod 4755 \/bin\/rm\u5c31\u662f\u8bbe\u7f6e\u7684setuid\u4f4d\uff1b<\/p>\n
setuid\u8bbe\u7f6e\u65b9\u6cd5\uff1a<\/strong><\/p>\n\u5176\u5b9e\u5c31\u662f\u5728\u6211\u4eec\u901a\u8fc7chmod\u8bbe\u7f6e\u6587\u4ef6\u6216\u76ee\u5f55\u6743\u9650\u4f4d\u7684\u6570\u5b57\u6743\u9650\u4e3a\u7684\u6570\u5b57\u65b9\u6cd5\u7684\u524d\u9762\u591a\u52a0\u4e00\u4e2a\u6570\u5b574.\u6bd4\u5982\uff1a<\/p>\n
[root@localhost ~]# chmod 4755 \/bin\/rm #\u8bbe\u7f6erm\u7684\u6743\u9650\u4e3a4755\uff0c\u8fd9\u6837\u5c31\u628asetuid\u4f4d\u8bbe\u7f6e\u597d\u4e86<\/code><\/pre>\nsetgid\u8bbe\u7f6e\u65b9\u6cd5\uff1a<\/strong><\/p>\nsetgid\u4f4d\u5360\u7528\u7684\u662f\u516b\u8fdb\u5236\u76842000\uff0c\u5176\u5b9e\u5c31\u662f\u5728\u6211\u4eec\u901a\u8fc7chmod\u8bbe\u7f6e\u6587\u4ef6\u6216\u76ee\u5f55\u6743\u9650\u4f4d\u7684\u6570\u5b57\u6743\u9650\u65b9\u6cd5\u7684\u524d\u9762\u591a\u52a0\u4e00\u4e2a\u6570\u5b572.\u6211\u4eec\u4e0b\u9762\u4e3e\u4e2a\u4f8b\u5b50\uff1a<\/p>\n
[root@localhost ~]# cd \/home\/\n[root@localhost home]# mkdir student_dir\n[root@localhost home]# ls -ld student_dir\/\ndrwxr-xr-x 2 root root 4096 May 2 05:25 student_dir\/\n[root@localhost home]# chmod 2755 student_dir\/\n[root@localhost home]# ls -ld student_dir\/\ndrwxr-sr-x 2 root root 4096 May 2 05:25 student_dir<\/code><\/pre>\n\u6211\u4eec\u770b\u5230student_dir\u8fd9\u4e2a\u76ee\u5f55\uff0c\u7ecf\u8fc7\u6539\u53d8\u6743\u9650\u540e\u7684\u76ee\u5f55\u6240\u5f52\u5c5e\u7528\u6237\u7ec4\u7684\u90a3\u4e09\u4e2a\u6743\u9650\u4f4dr-s\u3002<\/p>\n
\u7279\u522b\u63d0\u9192\uff1a\u5982\u679c\u6211\u4eec\u89c1\u5230\u7684\u662f\u5c0f\u5199\u7684s\uff0c\u8868\u660e\u6587\u4ef6\u6240\u5f52\u5c5e\u7684\u7528\u6237\u7ec4\u4f4d\u6709\u6267\u884c\u6743\u9650x\u3002\u56e0\u4e3a\u6211\u4eec\u7528\u4e862755\uff0c\u610f\u601d\u662f\u8bf4\u6587\u4ef6\u5c5e\u4e3b\u62e5\u6709\u53ef\u8bfb\u53ef\u5199\u53ef\u6267\u884c\uff0c\u6240\u5f52\u5c5e\u7684\u7528\u6237\u7ec4\u62e5\u6709\u53ef\u8bfb\u53ef\u6267\u884c\u6743\u9650\uff0c\u5e76\u4e14\u8bbe\u7f6e\u4e86setuid\uff0c\u6240\u4ee5\u8fd9\u65f6\u672c\u6765\u6587\u4ef6\u6240\u5f52\u5c5e\u7684\u7528\u6237\u7ec4\u62e5\u6709r-x\uff0c\u73b0\u5728\u52a0\u4e86setgid\u4f4d\uff0c\u5c31\u628a\u5176\u4e2d\u7684x\u6362\u6210\u4e86s\u3002\u5982\u679c\u6587\u4ef6\u6240\u5f52\u5c5e\u7684\u7528\u6237\u7ec4\u6ca1\u6709\u6267\u884c\u6743\u9650\uff0c\u8fd9\u4e2a\u6743\u9650\u5e94\u8be5\u662fS\u3002\u540c\u7406setuid\u4f4d\u4e2d\u7684\u5927\u5199S\u548c\u5c0f\u5199\u7684s\uff0c\u4e5f\u662f\u8fd9\u4e2a\u539f\u7406\u3002<\/p>\n
\u89c1\u4e0b\u9762\u7684\u4f8b\u5b50\uff1a\u5982\u679c\u672c\u6765\u5728\u8be5\u4f4d\u4e0a\u6709x\uff0c\u5219\u8fd9\u4e9b\u7279\u6b8a\u6807\u5fd7\u663e\u793a\u4e3a\u5c0f\u5199\u5b57\u6bcd\uff08s,s,t\uff09\u3002\u5426\u5219\uff0c\u663e\u793a\u4e3a\u5927\u5199\u5b57\u6bcd\uff08S,S,T\uff09\u3002<\/p>\n
[root@localhost home]# chmod 2740 student_dir\/\n[root@localhost home]# ls -ld student_dir\/\ndrwxr-S--- 2 root root 4096 May 2 05:25 student_dir\/<\/code><\/pre>\n\u8fd9\u4e2a\u4f8b\u5b50\u662f\u56e0\u4e3a\u76ee\u5f55student_dir\u6240\u5f52\u5c5e\u7684\u7ec4\u6ca1\u6709\u6267\u884c\u6743\u9650\uff0c\u8fd9\u65f6\u672c\u6765\u5728\u6267\u884c\u6743\u9650\u4f4d\u4e0a\u663e\u793a-\uff0c\u7531\u4e8e\u6709\u4e86setuid\uff0c\u6240\u4ee5\u663e\u793a\u4e3aS\u3002<\/p>\n
\u5982\u679c\u6211\u4eec\u4e3a\u4e00\u4e2a\u6587\u4ef6ett.txt\u7684\u8bbe\u7f6e\u6743\u9650\u62e5\u6709\u5c5e\u4e3b\u53ef\u8bfb\u3001\u53ef\u5199\u3001\u53ef\u6267\u884c\u6743\u9650\uff0c\u6240\u5f52\u5c5e\u7684\u7ec4\u62e5\u6709\u53ef\u8bfb\u3001\u53ef\u6267\u884c\u6743\u9650\uff0c\u5176\u4ed6\u7528\u6237\u53ef\u8bfb\u3001\u53ef\u6267\u884c\u6743\u9650\uff0c\u5e76\u4e14\u540c\u65f6\u8bbe\u7f6esetuid\u548csetgid\u4f4d\uff0c\u6211\u4eec\u5e94\u8be5\u600e\u4e48\u8fd0\u884c\u547d\u4ee4\u5462\uff1f<\/p>\n
[root@localhost oldboy]# touch ett.txt\n[root@localhost oldboy]# ls -l ett.txt \n-rw-r--r-- 1 root root 0 May 2 06:49 ett.txt\n[root@localhost oldboy]# chmod 6755 ett.txt #\u540c\u65f6\u8bbe\u7f6esetuid\uff0csetgid\u7684\u547d\u4ee4\u529e\u6cd5\u4e3a6755\uff0c6\u76f8\u5f53\u4e8e4+2\n[root@localhost oldboy]# ls -l ett.txt \n-rwsr-sr-x 1 root root 0 May 2 06:49 ett.txt<\/code><\/pre>\n\u6240\u4ee5\uff0c\u540c\u65f6\u8bbe\u7f6esetuid\u548csetgid\uff0c\u5c31\u662f\u628asetuid\u548csetgid\u4e24\u4e2a\u516b\u8fdb\u4f4d\u7684\u503c\u76f8\u52a0\uff084000+2000=6000\uff09\uff0c\u7136\u540e\u52a0\u4e0a\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u6743\u9650\u4f4d\u7684\u4e09\u4e2a\u6570\u503c\uff08\u4e0a\u9762\u7684\u4f8b\u5b50\u662f755\uff09\uff0c\u7136\u540e\u901a\u8fc7chmod\u8fd0\u884c\u5c31\u884c\u4e86\uff0c\u7136\u540e\u4e0a\u9762\u4f8b\u5b50\u4e2d\u7528\u4e866755.<\/p>\n
\u7279\u6b8a\u6743\u9650\u4f4d\u5b57\u7b26\u5f0f\u8bed\u6cd5\u65b9\u6cd5<\/h3>\n \u8fd8\u662f\u7528chmod\u7684\u5b57\u7b26\u5f0f\u8bed\u6cd5\uff0c\u901a\u8fc7u+s\u6216u-s\u6765\u589e\u51cfsetuid\u4f4d\uff0c\u540c\u7406\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7g+s\u6765\u589e\u51cfsetgid\u4f4d\uff1b<\/p>\n
[root@localhost oldboy]# touch comment.txt\n[root@localhost oldboy]# ls -l comment.txt \n-rw-r--r-- 1 root root 0 May 2 06:59 comment.txt\n[root@localhost oldboy]# chmod u+s comment.txt \n[root@localhost oldboy]# ls -l comment.txt \n-rwSr--r-- 1 root root 0 May 2 06:59 comment.txt<\/code><\/pre>\n\u6211\u4eec\u4e5f\u53ef\u4ee5\u7528file\u547d\u4ee4\u6765\u67e5\u770bsetuid\u548csetgid\u4f4d\uff0c\u5f53\u7136\u4e5f\u80fd\u7528file\u6765\u67e5\u770b\u6587\u4ef6\u7684\u7c7b\u578b\uff1b<\/p>\n
\u6bd4\u5982\uff1a<\/p>\n
[root@localhost oldboy]# file \/usr\/bin\/passwd \n\/usr\/bin\/passwd: setuid ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU\/Linux 2.6.9, dynamically linked (uses shared libs), stripped<\/code><\/pre>\n\u9ecf\u8d34\u4f4d\u53ca\u8bbe\u7f6e\u65b9\u6cd5<\/h3>\n \n \u9ecf\u8d34\u4f4d\u7684\u7406\u89e3\uff0c\u6211\u4eec\u8fd8\u662f\u5148\u770b\u4e00\u4e2a\u4f8b\u5b50<\/p>\n
[root@localhost oldboy]# ls -ld \/tmp\/\ndrwxrwxrwt 17 root root 4096 May 2 06:34 \/tmp\/<\/code><\/pre>\n\u6211\u4eec\u770b\u5230\/tmp\u6743\u9650\u4f4d\u6700\u540e\u7684\u4e00\u4e2a\u5b57\u6bcd\u662ft\u3002\u8fd9\u5c31\u662f\u8bbe\u7f6e\u4e86\u9ecf\u8d34\u4f4d\u3002<\/p>\n
\u9ecf\u8d34\u4f4d\u7684\u8bbe\u7f6e\uff0c\u7528\u516b\u8fdb\u5236\u76841000\u4f4d\u6765\u8868\u793a\u3002\u6bd4\u5982<\/p>\n
[root@localhost oldboy]# mkdir zgy_dir\n[root@localhost oldboy]# ls -ld zgy_dir\/\ndrwxr-xr-x 2 root root 4096 May 2 07:04 zgy_dir\/\n[root@localhost oldboy]# chmod 1755 zgy_dir\/ #\u8bbe\u7f6e\u9ecf\u8d34\u4f4d\u7684\u6570\u5b57\u6743\u9650\u65b9\u6cd5\n[root@localhost oldboy]# ls -ld zgy_dir\/\ndrwxr-xr-t 2 root root 4096 May 2 07:04 zgy_dir\/<\/code><\/pre>\n\u4e5f\u53ef\u4ee5\u7528chmod\u7684\u5b57\u7b26\u5f0f\u8bed\u6cd5\u6765\u8bbe\u7f6e\u3002\u7528o+t\u8868\u793a\u8bbe\u7f6e\u9ecf\u8d34\u4f4d\uff0c\u7528o-t\u8868\u793a\u53d6\u6d88\u9ecf\u8d34\u4f4d\uff1b<\/p>\n
[root@localhost oldboy]# ls -ld zgy_dir\/\ndrwxr-xr-x 2 root root 4096 May 2 07:04 zgy_dir\/\n[root@localhost oldboy]# chmod o+t zgy_dir\/\n[root@localhost oldboy]# ls -ld zgy_dir\/ \ndrwxr-xr-t 2 root root 4096 May 2 07:04 zgy_dir\/ #\u662f\u4e0d\u662f\u6709\u4e86\u9ecf\u8d34\u4f4d\u7684\u8bbe\u7f6e\uff0c\u5b57\u6bcdt\u5c31\u662f\u3002<\/code><\/pre>\n\u9ecf\u8d34\u4f4d\u7684\u529f\u80fd\u9650\u5236\u4e5f\u5f88\u5c11\u7528\u4e86\uff0c\u4e0d\u8fc7\u5bf9\u4e8e\u50cf\/tmp\u76ee\u5f55\u8fd9\u6837\u7684\uff0c\u662f\u6574\u4e2a\u7cfb\u7edf\u4e34\u65f6\u6587\u4ef6\u5b58\u653e\u5730\uff0c\u8fd8\u662f\u6709\u70b9\u610f\u4e49\u3002\u4e00\u4e2a\u76ee\u5f55\u5373\u4f7f\u5b83\u7684\u6240\u6709\u6743\u9650\u90fd\u5f00\u653erwxrwxrwx\uff0c\u5982\u679c\u662f\u8bbe\u7f6e\u4e86\u9ecf\u8d34\u4f4d\uff0c\u9664\u975e\u76ee\u5f55\u7684\u5c5e\u4e3b\u548croot\u7528\u6237\u6709\u6743\u9650\u5220\u9664\u5b83\uff0c\u9664\u6b64\u4e4b\u5916\u5176\u4ed6\u7528\u6237\u4e0d\u80fd\u5220\u9664\u8fd9\u4e2a\u76ee\u5f55\u3002\u7528\u9014\u4e00\u822c\u662f\u628a\u4e00\u4e2a\u6587\u4ef6\u5939\u7684\u6743\u9650\u90fd\u6253\u5f00\uff0c\u7136\u540e\u6765\u5171\u4eab\u6587\u4ef6\uff0c\u50cf\/tmp\u76ee\u5f55\u4e00\u6837\uff0c\u65b9\u4fbf\u5e26\u6765\u7684\u5b89\u5168\u9690\u60a3\uff0c\u751f\u4ea7\u73af\u5883\u6211\u4eec\u4e00\u822c\u4e0d\u8fd9\u6837\u4f7f\u7528\uff01<\/p>\n
\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u5f52\u5c5e\u5173\u7cfb<\/strong><\/h2>\n\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u5f52\u5c5e\u5173\u7cfb\u4e3b\u8981\u5b9a\u4e49\u6587\u4ef6\u6216\u5f52\u5c5e\u54ea\u4e2a\u7528\u6237\u6240\u6709\u53ca\u5f52\u4e8e\u54ea\u4e2a\u7528\u6237\u7ec4\u6240\u6709\u3002<\/p>\n
[root@localhost oldboy]# ls -l oldboy\n-rw-r--r-- 1 root root 5 May 1 09:57 oldboy<\/code><\/pre>\n\u4e0a\u9762\u7684\u4f8b\u5b50\u8868\u793a\uff0coldboy\u8fd9\u4e2a\u6587\u4ef6\uff0c\u5176\u5c5e\u4e3b\u662froot\uff0c\u5f52<\/p>\n
\u5c5e\u7684\u7ec4\u662froot\u7528\u6237\u7ec4\uff0c\u800croot\u7528\u6237\u6240\u62e5\u6709\u7684\u6743\u9650\u662frw-\uff0croot\u7528\u6237\u7ec4\u62e5\u6709\u7684\u6743\u9650\u662fr--\u3002<\/p>\n
\u6709\u65f6\u6211\u4eec\u53ef\u80fd\u4e0d\u7406\u89e3\uff0c\u4e3a\u4ec0\u4e48Linux\u8981\u8bbe\u7f6e\u6587\u4ef6\u7684\u5c5e\u4e3b\u3001\u5c5e\u7ec4\uff0c\u4e3a\u4ec0\u4e48\u8fd8\u8981\u4e3a\u5c5e\u4e3b\u3001\u5c5e\u7ec4\u548c\u5176\u4ed6\u7528\u6237\u90fd\u8981\u8bbe\u7f6e\u6743\u9650\u5462\uff1f\u6211\u4eec\u5728\u4ee5\u524d\u7684\u6587\u6863\u8bf4\u8fc7\uff0cLinux\u662f\u591a\u7528\u6237\u7684\u64cd\u4f5c\u7cfb\u7edf\uff0c\u6587\u4ef6\u7684\u5b89\u5168\u6027\u5bf9Linux\u662f\u6781\u4e3a\u91cd\u8981\u7684\uff0cLinux\u7684\u5b89\u5168\u6027\u4e3b\u8981\u8868\u793a\u5728\u7528\u6237\u7ba1\u7406\u548c\u6743\u9650\uff08\u7528\u6237\u7684\u6743\u9650\u53ca\u6587\u4ef6\u7684\u6743\u9650\uff09\u7ba1\u7406\u4e0a\u3002<\/p>\n
\u6539\u53d8\u6587\u4ef6\u6240\u5c5e\u5173\u7cfb\u547d\u4ee4chown<\/h3>\n \u5f53\u6211\u4eec\u8981\u6539\u53d8\u4e00\u4e2a\u6587\u4ef6\u7684\u5c5e\u7ec4\u3002\u6211\u4eec\u6240\u4f7f\u7528\u7684\u7528\u6237\u5fc5\u987b\u662f\u8be5\u6587\u4ef6\u7684\u5c5e\u4e3b\u800c\u4e14\u540c\u65f6\u662f\u76ee\u6807\u5c5e\u7ec4\u6210\u5458\uff0c\u6216\u8d85\u7ea7\u7528\u6237\u3002\u53ea\u6709\u8d85\u7ea7\u7528\u6237\u624d\u80fd\u6539\u53d8\u6587\u4ef6\u7684\u5c5e\u4e3b\u3002<\/p>\n
chown \u8bed\u6cd5<\/strong><\/p>\nchown [\u9009\u9879]... [\u6240\u6709\u8005][:[\u7ec4]] \u6587\u4ef6...<\/code><\/pre>\n\u4e3e\u4f8b\uff1a\u5c06oldboy\u6587\u4ef6\u7684\u5c5e\u4e3b\u6539\u4e3aoldboy\u7528\u6237<\/p>\n
[root@localhost oldboy]# ls -l oldboy\n-rw-r--r-- 1 root root 5 May 1 09:57 oldboy\n[root@localhost ~]# chown oldboy:root oldboy #\u8fd9\u91cc\u5192\u53f7\u4e5f\u53ef\u4ee5\u6362\u6210\u70b9(.)\n[root@localhost oldboy]# ls -l oldboy\n-rw-r--r-- 1 oldboy root 5 May 1 09:57 oldboy<\/code><\/pre>\n\u8bf4\u660e\uff1achown \u6240\u63a5\u7684\u65b0\u7684\u5c5e\u4e3b\u548c\u65b0\u7684\u5c5e\u7ec4\u4e4b\u95f4\u5e94\u8be5\u4ee5.\u6216\uff1a\u8fde\u63a5\uff0c\u5c5e\u4e3b\u548c\u5c5e\u7ec4\u4efb\u610f\u4e4b\u4e00\u53ef\u4ee5\u4e3a\u7a7a\u3002\u5982\u679c\u5c5e\u4e3b\u4e3a\u7a7a\uff0c\u5e94\u8be5\u662f\uff1a\u5c5e\u7ec4\uff1b\u5982\u679c\u5c5e\u7ec4\u4e3a\u7a7a\uff0c\u5c31\u4e0d\u5fc5\u9700\u8981.\u6216:\u4e86\u3002<\/p>\n
root@localhost ~]# mkdir -p \/test\/oldboy\n[root@localhost ~]# cd \/test\/oldboy\/\n[root@localhost oldboy]# touch oldboy.txt\n[root@localhost oldboy]# ls -l oldboy.txt \n-rw-r--r-- 1 root root 0 May 3 08:09 oldboy.txt\n[root@localhost oldboy]# chown zgy oldboy.txt #\u628aoldboy.txt\u7684\u5c5e\u4e3b\u6539\u4e3azgy\n[root@localhost oldboy]# ls -l oldboy.txt \n-rw-r--r-- 1 zgy root 0 May 3 08:09 oldboy.txt\n[root@localhost oldboy]# chown :zgy oldboy.txt \n[root@localhost oldboy]# ls -l oldboy.txt \n-rw-r--r-- 1 zgy zgy 0 May 3 08:09 oldboy.txt\n[root@localhost oldboy]# chown root:etiantian oldboy.txt #\u628aoldboy.txt\u7684\u5c5e\u4e3b\u6539\u4e3aroot\uff0c\u628a\u5c5e\u7ec4\u6539\u6210etiantian\u7528\u6237\u7ec4\n[root@localhost oldboy]# ls -l oldboy.txt \n-rw-r--r-- 1 root etiantian 0 May 3 08:09 oldboy.txt\n\u7279\u522b\u63d0\u793a\uff1a\u8981\u4fee\u6539\u7684\u7528\u6237\u548c\u7ec4\u9119\u89c6\u662f\u7cfb\u7edf\u4e2d\u5df2\u7ecf\u5b58\u5728\u7684\u3002<\/code><\/pre>\nchown\u4e5f\u63d0\u4f9b\u4e86-R\u53c2\u6570\uff0c\u8fd9\u4e2a\u53c2\u6570\u5bf9\u76ee\u5f55\u6539\u53d8\u5c5e\u4e3b\u548c\u5c5e\u7ec4\u6781\u4e3a\u6709\u7528\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u52a0-R\u53c2\u6570\u6765\u6539\u53d8\u67d0\u4e2a\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u6587\u4ef6\u5230\u65b0\u7684\u5c5e\u4e3b\u6216\u5c5e\u7ec4\uff1b<\/p>\n
[root@localhost oldboy]# mkdir zgy_dir\n[root@localhost oldboy]# ls -ld zgy_dir\/\ndrwxr-xr-x 2 root root 4096 May 3 08:26 zgy_dir\/\n[root@localhost oldboy]# mkdir zgy_dir\n[root@localhost oldboy]# ls -ld zgy_dir\/\ndrwxr-xr-x 2 root root 4096 May 3 08:26 zgy_dir\/<\/code><\/pre>\n\u6539\u53d8\u6587\u4ef6\u7684\u6570\u7ec4\u547d\u4ee4chgrp<\/h3>\n \u8bed\u6cd5\uff1a<\/p>\n
chgrp [\u53c2\u6570\u9009\u9879]... \u7ec4 \u6587\u4ef6<\/code><\/pre>\n\u5b83\u7684\u7528\u6237\u548cchown\u7c7b\u4f3c\uff0c\u53ea\u4e0d\u8fc7\u5b83\u4ec5\u662f\u7528\u6765\u6539\u53d8\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u5c5e\u7ec4\u7684\uff1b-R\u53c2\u6570\u7528\u4e8e\u76ee\u5f55\u53ca\u76ee\u5f55\u4e0b\u6240\u6709\u6587\u4ef6\u6539\u53d8\u5c5e\u7ec4\u7684\u3002\u8fd9\u548cchown\u4e5f\u662f\u4e00\u6837\u7684\uff0c\u53ef\u4ee5\u628achgrp\u770b\u4f5c\u662fchown\u7684\u5b50\u96c6\u3002\u4e00\u822c\u4f1a\u7528chown\u5373\u53ef\u3002\u6211\u4eec\u6765\u4e24\u4e2a\u4f8b\u5b50\u7b80\u5355\u9610\u8ff0\u4e0bchgrp\u7684\u7528\u6cd5<\/p>\n
\u4f8b\u5b501\uff1a<\/p>\n
[root@localhost oldboy]# ls -l oldboy.txt \n-rw-r--r-- 1 root root 0 May 3 08:09 oldboy.txt\n[root@localhost oldboy]# chgrp zgy oldboy.txt \n[root@localhost oldboy]# ls -l oldboy.txt \n-rw-r--r-- 1 root zgy 0 May 3 08:09 oldboy.txt<\/code><\/pre>\n\u6587\u4ef6\u5c5e\u4e3b\u548c\u5c5e\u7ec4\u7684\u7279\u6b8a\u60c5\u51b5<\/h3>\n[root@localhost oldboy]# ls -l oldboy.txt \n-rw-r--r-- 1 root zgy 0 May 3 08:09 oldboy.txt\n[root@localhost oldboy]# chown ett oldboy.txt \n[root@localhost oldboy]# ls -l oldboy.txt \n-rw-r--r-- 1 ett zgy 0 May 3 08:09 oldboy.txt\n[root@localhost oldboy]# userdel ett\n[root@localhost oldboy]# ls -l oldboy.txt \n-rw-r--r-- 1 502 zgy 0 May 3 08:09 oldboy.txt\n[root@localhost oldboy]# useradd ett\nCreating mailbox file: File exists\nuseradd: warning: the home directory already exists.\nNot copying any file from skel directory into it.\n[root@localhost oldboy]# chown ett:ett oldboy.txt \n[root@localhost oldboy]# ls -l oldboy.txt \n-rw-r--r-- 1 ett ett 0 May 3 08:09 oldboy.txt\n[root@localhost oldboy]# userdel ett\n[root@localhost oldboy]# ls -l oldboy.txt \n-rw-r--r-- 1 504 504 0 May 3 08:09 oldboy.txt\n[root@localhost oldboy]# useradd oldboy123\n[root@localhost oldboy]# chown oldboy123:oldboy123 oldboy.txt \n[root@localhost oldboy]# ls -l oldboy.txt \n-rw-r--r-- 1 oldboy123 oldboy123 0 May 3 08:09 oldboy.txt\n[root@localhost oldboy]# userdel oldboy123\n[root@localhost oldboy]# cd \/home\/oldboy123\/\n[root@localhost oldboy123]# ls -l oldboy.txt \nls: oldboy.txt: No such file or directory\n[root@localhost oldboy123]# cd -\n\/test\/oldboy\n[root@localhost oldboy]# ls -l oldboy.txt \n-rw-r--r-- 1 504 504 0 May 3 08:09 oldboy.txt<\/code><\/pre>\n\u4e0a\u9762\u7684\u4f8b\u5b50\u662f\u4e0d\u662f\u6709\u70b9\u5947\u602a\uff1f\u56e0\u4e3a\u5b83\u7684\u5c5e\u4e3b\u548c\u6570\u5b57\u90fd\u662f\u4e00\u4e2a\u6570\u503c\uff1b\u8fd9\u662f\u4e3a\u4ec0\u4e48\u5462\uff1f\u51fa\u73b0\u8fd9\u79cd\u60c5\u51b5\u7684\u539f\u56e0\u662f\u7cfb\u7edf\u4e2d\u4e0d\u5b58\u653e\u4e0e\u4e4b\u5bf9\u5e94\u7684\u7528\u6237\uff0c\u6240\u6709\u53ea\u80fd\u4ee5\u6570\u5b57\u5f62\u5f0f\u663e\u793a\u4e86\u3002\u4e5f\u5c31\u662f\u8bf4\u4e00\u65e6\u5220\u9664\u4e86\u7528\u6237\uff0c\u800c\u6587\u4ef6\u539f\u6765\u6587\u4ef6\u7684\u7684\u5c5e\u4e3b\u6216\u5c5e\u7ec4\u662f\u8fd9\u4e2a\u7528\u6237\uff0c\u90a3\u4e48\u8be5\u6587\u4ef6\u7684\u5c5e\u4e3b\u6216\u5c5e\u7ec4\u5c31\u4f1a\u53d8\u6210\u6570\u5b57\u5f62\u5f0f\u3002<\/p>\n
\u6587\u4ef6\u88ab\u4fee\u6539\u6216\u88ab\u8bbf\u95ee\u7684\u65f6\u95f4<\/h2>\n \u6211\u4eec\u901a\u8fc7\u67e5\u770b\u6587\u4ef6\u7684\u5c5e\u6027\u65f6\uff0c\u4f1a\u53d1\u73b0\u5b83\u7684\u65f6\u95f4\u6807\u8bb0\u3002\u8fd9\u4e2a\u65f6\u95f4\u5e76\u4e0d\u4ee3\u8868\u6587\u4ef6\u88ab\u521b\u5efa\u7684\u65f6\u5019\uff0c\u4ed6\u662f\u4ee3\u8868\u6587\u4ef6\u88ab\u8bbf\u95ee\u6216\u88ab\u4fee\u6539\u7684\u65f6\u95f4\u3002\u6587\u4ef6\u88ab\u4fee\u6539\u7684\u65f6\u95f4\u6bd4\u8f83\u597d\u7406\u89e3\uff0c\u6bd4\u5982\u6211\u4eec\u53ef\u4ee5\u7528\u7f16\u8f91\u5668\u6765\u4fee\u6539\u6587\u672c\u6587\u4ef6\uff0c\u7136\u540e\u4fdd\u5b58\u4e00\u4e0b\uff0c\u8fd9\u6837\u6587\u4ef6\u7684\u65f6\u95f4\u5c31\u53d8\u4e86\u3002<\/p>\n
\u5f53\u7136\u4e5f\u6709\u5176\u4ed6\u7684\u5de5\u5177\u4e0d\u4fee\u6539\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u53ea\u4fee\u6539\u6587\u4ef6\u7684\u65f6\u95f4\uff0c\u8fd9\u65f6\u53ef\u4ee5\u88ab\u79f0\u4e3a\u8bbf\u95ee\u65f6\u95f4\uff0c\u6bd4\u5982touch\u5de5\u5177\u80fd\u8fbe\u5230\u80fd\u8fbe\u5230\u8fd9\u4e2a\u76ee\u7684\u3002<\/p>\n
[root@localhost oldboy]# ls -l oldboy.txt \n-rw-r--r-- 1 zgy zgy 0 May 3 08:09 oldboy.txt\n[root@localhost oldboy]# touch oldboy.txt #\u66f4\u6539\u6587\u4ef6\u7684\u8bbf\u95ee\u65f6\u95f4\u4e3a\u5f53\u524d\u7cfb\u7edf\u65f6\u95f4\n[root@localhost oldboy]# ls -l oldboy.txt \n-rw-r--r-- 1 zgy zgy 0 May 3 09:30 oldboy.txt<\/code><\/pre>\n\u5173\u4e8etouch\u7684\u7528\u6cd5\uff0c\u66f4\u591a\u7684\u8bf7\u53c2\u89c1\uff1aman touch \u6216touch --help<\/p>\n
\u6587\u4ef6\u5c5e\u6027\u548c\u6587\u4ef6\u7cfb\u7edf\u5c5e\u6027\u7684\u5173\u7cfb<\/h2>\n \u6587\u4ef6\u7cfb\u7edf\u7684\u7279\u6027\u51b3\u5b9a\u7740\u6587\u4ef6\u5c5e\u6027\u7684\u5b9a\u4e49\u548c\u4fee\u6539\uff0c\u6bd4\u5982\u6211\u4eecchattr\u6765\u9501\u5b9a\u4e00\u4e2a\u6587\u4ef6\u4e3a\u4e0d\u53ef\u4fee\u6539\u6216\u4e0d\u53ef\u5220\u9664\u65f6\uff0c\u8981\u7528\u5230chattr\u7684+i\u53c2\u6570\uff1b\u8fd9\u5728ext2\u548cext3\u6587\u4ef6\u7cfb\u7edf\u662f\u6709\u6548\u7684\uff0c\u4f46\u5728reiserfs\u6587\u4ef6\u7cfb\u7edf\u662f\u6ca1\u6709\u4efb\u4f55\u6548\u679c\u7684\uff1b<\/p>\n
[root@localhost oldboy]# chattr +i oldboy.txt \n[root@localhost oldboy]# lsattr oldboy.txt \n----i-------- oldboy.txt\n[root@localhost oldboy]# rm -f oldboy.txt \nrm: cannot remove `oldboy.txt': Operation not permitted\n\u6ce8\uff1a\u5982\u679c\u628aoldboy.txt \u53d8\u6210\u53ef\u4fee\u6539\u53ef\u5220\u9664\uff0c\u5e94\u8be5\u7528-i\u53c2\u6570\uff1b<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"Linux \u57fa\u7840\u6559\u7a0b-\u6587\u4ef6\u76ee\u5f55\u53ca\u5c5e\u6027 \u4e00\u3001Linux \u7cfb\u7edf\u76ee\u5f55\u7ed3\u6784 \u6211\u4eec\u6765\u4e86\u89e3\u4e0b Linux \u7cfb\u7edf\u7684\u76ee\u5f55\u7ed3\u6784\uff0c<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[104,105,103,106],"yoast_head":"\n
01-Linux \u57fa\u7840\u6559\u7a0b-\u6587\u4ef6\u76ee\u5f55\u53ca\u5c5e\u6027 - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n