{"id":181464,"date":"2020-05-06T00:41:10","date_gmt":"2020-05-05T16:41:10","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=181464"},"modified":"2022-07-22T21:07:59","modified_gmt":"2022-07-22T13:07:59","slug":"basic-learning-05","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/basic-learning-05.html","title":{"rendered":"\u7b2c5\u7ae0 \u7528\u6237\u8eab\u4efd\u4e0e\u6587\u4ef6\u6743\u9650"},"content":{"rendered":"

\u7ae0\u8282\u7b80\u8ff0\uff1a<\/strong><\/span><\/p>\n

Linux\u662f\u4e00\u4e2a\u591a\u7528\u6237\u3001\u591a\u4efb\u52a1\u7684\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5177\u6709\u5f88\u597d\u7684\u7a33\u5b9a\u6027\u4e0e\u5b89\u5168\u6027\uff0c\u5728\u5e55\u540e\u4fdd\u969cLinux\u7cfb\u7edf\u7684\u5b89\u5168\u5219\u662f\u4e00\u7cfb\u5217\u590d\u6742\u7684\u914d\u7f6e\u5de5\u4f5c\u3002\u672c\u7ae0\u5c06\u8be6\u7ec6\u8bb2\u89e3\u6587\u4ef6\u7684\u6240\u6709\u8005\u3001\u6240\u5c5e\u7ec4\u4ee5\u53ca\u5176\u4ed6\u4eba\u53ef\u5bf9\u6587\u4ef6\u8fdb\u884c\u7684\u8bfb\uff08r\uff09\u3001\u5199\uff08w\uff09\u3001\u6267\u884c\uff08x\uff09\u7b49\u64cd\u4f5c\uff0c\u8fd8\u5c06\u4ecb\u7ecd\u5982\u4f55\u5728Linux\u7cfb\u7edf\u4e2d\u6dfb\u52a0\u3001\u5220\u9664\u3001\u4fee\u6539\u7528\u6237\u8d26\u6237\u4fe1\u606f\u3002<\/p>\n

\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528SUID\u3001SGID\u4e0eSBIT\u7279\u6b8a\u6743\u9650\u66f4\u52a0\u7075\u6d3b\u5730\u8bbe\u7f6e\u7cfb\u7edf\u6743\u9650\uff0c\u6765\u5f25\u8865\u5bf9\u6587\u4ef6\u8bbe\u7f6e\u4e00\u822c\u64cd\u4f5c\u6743\u9650\u65f6\u6240\u5e26\u6765\u7684\u4e0d\u8db3\u3002\u9690\u85cf\u6743\u9650\u80fd\u591f\u7ed9\u7cfb\u7edf\u589e\u52a0\u4e00\u5c42\u9690\u5f62\u7684\u9632\u62a4\u5c42\uff0c\u8ba9\u9ed1\u5ba2\u6700\u591a\u53ea\u80fd\u67e5\u770b\u5173\u952e\u65e5\u5fd7\u4fe1\u606f\uff0c\u800c\u4e0d\u80fd\u7be1\u6539\u6216\u5220\u9664\u3002\u800c\u6587\u4ef6\u8bbf\u95ee\u63a7\u5236\u5217\u8868\uff08Access Control List\uff0cACL\uff09\u53ef\u4ee5\u8fdb\u4e00\u6b65\u8ba9\u5355\u4e00\u7528\u6237\u3001\u7528\u6237\u7ec4\u5bf9\u5355\u4e00\u6587\u4ef6\u6216\u76ee\u5f55\u8fdb\u884c\u7279\u6b8a\u7684\u6743\u9650\u8bbe\u7f6e\uff0c\u8ba9\u6587\u4ef6\u5177\u6709\u80fd\u6ee1\u8db3\u5de5\u4f5c\u9700\u6c42\u7684\u6700\u5c0f\u6743\u9650\u3002<\/p>\n

\u672c\u7ae0\u6700\u540e\u8fd8\u4f1a\u8bb2\u89e3\u5982\u4f55\u4f7f\u7528su\u547d\u4ee4\u4e0esudo\u670d\u52a1\u8ba9\u666e\u901a\u7528\u6237\u5177\u5907\u7ba1\u7406\u5458\u7684\u6743\u9650\uff0c\u8fd9\u4e0d\u4ec5\u80fd\u591f\u6ee1\u8db3\u65e5\u5e38\u7684\u5de5\u4f5c\u9700\u6c42\uff0c\u8fd8\u53ef\u4ee5\u786e\u4fdd\u7cfb\u7edf\u7684\u5b89\u5168\u6027\u3002<\/p>\n

5.1 \u7528\u6237\u8eab\u4efd\u4e0e\u80fd\u529b<\/strong><\/span><\/h5>\n

\u53d7\u523020\u4e16\u7eaa70\u5e74\u4ee3\u8ba1\u7b97\u673a\u53d1\u5c55\u7684\u5f71\u54cd\uff0cLinux\u7cfb\u7edf\u7684\u8bbe\u8ba1\u521d\u8877\u4e4b\u4e00\u5c31\u662f\u4e3a\u4e86\u6ee1\u8db3\u591a\u4e2a\u7528\u6237\u540c\u65f6\u5de5\u4f5c\u7684\u9700\u6c42\uff0c\u56e0\u6b64\u5fc5\u987b\u5177\u5907\u5f88\u597d\u7684\u5b89\u5168\u6027\uff0c\u5c24\u5176\u662f\u4e0d\u80fd\u56e0\u4e3a\u4e00\u4e24\u4e2a\u670d\u52a1\u51fa\u9519\u800c\u5f71\u54cd\u5230\u6574\u53f0\u670d\u52a1\u5668\u3002\u5728\u7b2c1\u7ae0\u5b66\u4e60\u5b89\u88c5Linux\u64cd\u4f5c\u7cfb\u7edf\u65f6\uff0c\u7279\u522b\u8981\u6c42\u8bbe\u7f6eroot\u7ba1\u7406\u5458\u7684\u5bc6\u7801\uff0c\u8fd9\u4e2aroot\u7ba1\u7406\u5458\u5c31\u662f\u5b58\u5728\u4e8e\u6240\u6709\u7c7bUNIX\u7cfb\u7edf\u4e2d\u7684\u8d85\u7ea7\u7528\u6237\u3002\u5b83\u62e5\u6709\u6700\u9ad8\u7684\u7cfb\u7edf\u6240\u6709\u6743\uff0c\u80fd\u591f\u7ba1\u7406\u7cfb\u7edf\u7684\u5404\u9879\u529f\u80fd\uff0c\u5982\u6dfb\u52a0\/\u5220\u9664\u7528\u6237\u3001\u542f\u52a8\/\u5173\u95ed\u670d\u52a1\u8fdb\u7a0b\u3001\u5f00\u542f\/\u7981\u7528\u786c\u4ef6\u8bbe\u5907\u7b49\u3002\u867d\u7136\u4ee5root\u7ba1\u7406\u5458\u7684\u8eab\u4efd\u5de5\u4f5c\u65f6\u4e0d\u4f1a\u53d7\u5230\u7cfb\u7edf\u7684\u9650\u5236\uff0c\u4f46\u4fd7\u8bdd\u8bb2\u201c\u80fd\u529b\u8d8a\u5927\uff0c\u8d23\u4efb\u5c31\u8d8a\u5927\u201d\uff0c\u56e0\u6b64\u4e00\u65e6\u4f7f\u7528\u8fd9\u4e2a\u9ad8\u80fd\u7684root\u7ba1\u7406\u5458\u6743\u9650\u6267\u884c\u4e86\u9519\u8bef\u7684\u547d\u4ee4\uff0c\u53ef\u80fd\u4f1a\u76f4\u63a5\u6bc1\u6389\u6574\u4e2a\u7cfb\u7edf\u3002\u4f7f\u7528\u4e0e\u5426\uff0c\u786e\u5b9e\u9700\u8981\u597d\u597d\u6743\u8861\u4e00\u4e0b\u3002<\/p>\n

\u5728\u5b66\u4e60\u65f6\u662f\u5426\u8981\u4f7f\u7528root\u7ba1\u7406\u5458\u6743\u9650\u6765\u63a7\u5236\u6574\u4e2a\u7cfb\u7edf\u5462\uff1f\u5bf9\u4e8e\u8fd9\u4e2a\u95ee\u9898\uff0c\u7f51\u7edc\u4e0a\u6709\u5f88\u591a\u6587\u7ae0\u5efa\u8bae\u4ee5\u666e\u901a\u7528\u6237\u7684\u8eab\u4efd\u6765\u64cd\u4f5c\u2014\u8fd9\u662f\u4e00\u4e2a\u66f4\u5b89\u5168\u4e5f\u66f4\u201c\u65e0\u8d23\u4efb\u201d\u7684\u56de\u7b54\u3002\u4eca\u5929\uff0c\u5218\u9044\u8001\u5e08\u5c31\u8981\u5192\u5929\u4e0b\u4e4b\u5927\u4e0d\u97ea\u7ed9\u51fa\u81ea\u5df1\u7684\u5fc3\u5f97\u2014\u5f3a\u70c8\u63a8\u8350\u5927\u5bb6\u5728\u5b66\u4e60\u65f6\u4f7f\u7528root\u7ba1\u7406\u5458\u6743\u9650\uff01<\/p>\n

\u8fd9\u79cd\u4e3aroot\u7ba1\u7406\u5458\u6b63\u540d\u7684\u51b3\u7edd\u6001\u5ea6\u5728\u7f51\u7edc\u4e2d\u5e94\u8be5\u8fd8\u662f\u5f88\u5c11\u89c1\u7684\uff0c\u6211\u4e4b\u6240\u4ee5\u529b\u8350root\u7ba1\u7406\u5458\u6743\u9650\uff0c\u539f\u56e0\u5f88\u7b80\u5355\u3002\u56e0\u4e3a\u5728Linux\u7684\u5b66\u4e60\u8fc7\u7a0b\u4e2d\u5982\u679c\u4f7f\u7528\u666e\u901a\u7528\u6237\u8eab\u4efd\u8fdb\u884c\u64cd\u4f5c\uff0c\u5219\u5728\u914d\u7f6e\u670d\u52a1\u4e4b\u540e\u51fa\u73b0\u9519\u8bef\u65f6\u5f88\u96be\u5224\u65ad\u662f\u7cfb\u7edf\u81ea\u8eab\u7684\u95ee\u9898\u8fd8\u662f\u56e0\u4e3a\u6743\u9650\u4e0d\u8db3\u800c\u5bfc\u81f4\u7684\uff1b\u8fd9\u65e0\u7591\u4f1a\u7ed9\u5927\u5bb6\u7684\u5b66\u4e60\u8fc7\u7a0b\u5f92\u589e\u574e\u5777\u3002\u66f4\u4f55\u51b5\u6211\u4eec\u7684\u5b9e\u9a8c\u73af\u5883\u662f\u4f7f\u7528VMware\u865a\u62df\u673a\u8f6f\u4ef6\u642d\u5efa\u7684\uff0c\u53ef\u4ee5\u5c06\u5b89\u88c5\u597d\u7684\u7cfb\u7edf\u8bbe\u7f6e\u4e3a\u4e00\u6b21\u5feb\u7167\uff0c\u8fd9\u6837\u5373\u4fbf\u7cfb\u7edf\u5f7b\u5e95\u5d29\u6e83\u4e86\uff0c\u4e5f\u53ef\u4ee5\u57285\u79d2\u7684\u65f6\u95f4\u5185\u5feb\u901f\u8fd8\u539f\u51fa\u4e00\u53f0\u5168\u65b0\u7684\u7cfb\u7edf\uff0c\u800c\u4e0d\u7528\u62c5\u5fc3\u6570\u636e\u4e22\u5931\u3002<\/p>\n

\u603b\u4e4b\uff0c\u5218\u9044\u8001\u5e08\u5728\u57f9\u8bad\u65f6\u90fd\u63a8\u8350\u6bcf\u4f4d\u5b66\u751f\u4f7f\u7528root\u7ba1\u7406\u5458\u6743\u9650\u6765\u5b66\u4e60Linux\u7cfb\u7edf\uff0c\u7b49\u5230\u5de5\u4f5c\u65f6\u518d\u6839\u636e\u751f\u4ea7\u73af\u5883\u51b3\u5b9a\u4f7f\u7528\u54ea\u4e2a\u7528\u6237\u6743\u9650\uff1b\u8fd9\u4e9b\u4ec5\u4e0e\u9009\u62e9\u76f8\u5173\uff0c\u800c\u975e\u6280\u672f\u6027\u95ee\u9898\u3002<\/p>\n

\u53e6\u5916\uff0c\u5f88\u591a\u56fe\u4e66\u6216\u57f9\u8bad\u673a\u6784\u7684\u8001\u5e08\u4f1a\u8bb2\u5230\uff0cLinux\u7cfb\u7edf\u4e2d\u7684\u7ba1\u7406\u5458\u5c31\u662froot\u3002\u8fd9\u5176\u5b9e\u662f\u9519\u8bef\u7684\uff0cLinux\u7cfb\u7edf\u7684\u7ba1\u7406\u5458\u4e4b\u6240\u4ee5\u662froot\uff0c\u5e76\u4e0d\u662f\u56e0\u4e3a\u5b83\u7684\u540d\u5b57\u53ebroot\uff0c\u800c\u662f\u56e0\u4e3a\u8be5\u7528\u6237\u7684\u8eab\u4efd\u53f7\u7801\u5373UID\uff08User IDentification\uff09\u7684\u6570\u503c\u4e3a0\u3002\u5728Linux\u7cfb\u7edf\u4e2d\uff0cUID\u5c31\u50cf\u6211\u4eec\u7684\u8eab\u4efd\u8bc1\u53f7\u7801\u4e00\u6837\u5177\u6709\u552f\u4e00\u6027\uff0c\u56e0\u6b64\u53ef\u901a\u8fc7\u7528\u6237\u7684UID\u503c\u6765\u5224\u65ad\u7528\u6237\u8eab\u4efd\u3002\u5728RHEL 8\u7cfb\u7edf\u4e2d\uff0c\u7528\u6237\u8eab\u4efd\u6709\u4e0b\u9762\u8fd9\u4e9b\u3002<\/p>\n

\u7ba1\u7406\u5458UID\u4e3a0<\/strong>\uff1a\u7cfb\u7edf\u7684\u7ba1\u7406\u5458\u7528\u6237\u3002<\/p>\n

\u7cfb\u7edf\u7528\u6237UID\u4e3a1\uff5e999<\/strong>\uff1aLinux\u7cfb\u7edf\u4e3a\u4e86\u907f\u514d\u56e0\u67d0\u4e2a\u670d\u52a1\u7a0b\u5e8f\u51fa\u73b0\u6f0f\u6d1e\u800c\u88ab\u9ed1\u5ba2\u63d0\u6743\u81f3\u6574\u53f0\u670d\u52a1\u5668\uff0c\u9ed8\u8ba4\u670d\u52a1\u7a0b\u5e8f\u4f1a\u7531\u72ec\u7acb\u7684\u7cfb\u7edf\u7528\u6237\u8d1f\u8d23\u8fd0\u884c\uff0c\u8fdb\u800c\u6709\u6548\u63a7\u5236\u88ab\u7834\u574f\u8303\u56f4\u3002<\/p>\n

\u666e\u901a\u7528\u6237UID\u4ece1000\u5f00\u59cb<\/strong>\uff1a\u662f\u7531\u7ba1\u7406\u5458\u521b\u5efa\u7684\u7528\u4e8e\u65e5\u5e38\u5de5\u4f5c\u7684\u7528\u6237\u3002<\/p><\/blockquote>\n

\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cUID\u662f\u4e0d\u80fd\u51b2\u7a81\u7684\uff0c\u800c\u4e14\u7ba1\u7406\u5458\u521b\u5efa\u7684\u666e\u901a\u7528\u6237\u7684UID\u9ed8\u8ba4\u662f\u4ece1000\u5f00\u59cb\u7684\uff08\u5373\u4f7f\u524d\u9762\u6709\u95f2\u7f6e\u7684\u53f7\u7801\uff09\u3002<\/p>\n

\u4e3a\u4e86\u65b9\u4fbf\u7ba1\u7406\u5c5e\u4e8e\u540c\u4e00\u7ec4\u7684\u7528\u6237\uff0cLinux\u7cfb\u7edf\u4e2d\u8fd8\u5f15\u5165\u4e86\u7528\u6237\u7ec4\u7684\u6982\u5ff5\u3002\u901a\u8fc7\u4f7f\u7528\u7528\u6237\u7ec4\u53f7\u7801\uff08GID\uff0cGroup IDentification\uff09\uff0c\u53ef\u4ee5\u628a\u591a\u4e2a\u7528\u6237\u52a0\u5165\u5230\u540c\u4e00\u4e2a\u7ec4\u4e2d\uff0c\u4ece\u800c\u65b9\u4fbf\u4e3a\u7ec4\u4e2d\u7684\u7528\u6237\u7edf\u4e00\u89c4\u5212\u6743\u9650\u6216\u6307\u5b9a\u4efb\u52a1\u3002\u5047\u8bbe\u4e00\u4e2a\u516c\u53f8\u4e2d\u6709\u591a\u4e2a\u90e8\u95e8\uff0c\u6bcf\u4e2a\u90e8\u95e8\u4e2d\u53c8\u6709\u5f88\u591a\u5458\u5de5\uff0c\u5982\u679c\u53ea\u60f3\u8ba9\u5458\u5de5\u8bbf\u95ee\u672c\u90e8\u95e8\u5185\u7684\u8d44\u6e90\uff0c\u5219\u53ef\u4ee5\u9488\u5bf9\u90e8\u95e8\u800c\u975e\u5177\u4f53\u7684\u5458\u5de5\u6765\u8bbe\u7f6e\u6743\u9650\u3002\u4f8b\u5982\uff0c\u901a\u8fc7\u5bf9\u6280\u672f\u90e8\u95e8\u8bbe\u7f6e\u6743\u9650\uff0c\u4f7f\u5f97\u53ea\u6709\u6280\u672f\u90e8\u95e8\u7684\u5458\u5de5\u53ef\u4ee5\u8bbf\u95ee\u516c\u53f8\u7684\u6570\u636e\u5e93\u4fe1\u606f\u7b49\u3002<\/p>\n

\u53e6\u5916\uff0c\u5728Linux\u7cfb\u7edf\u4e2d\u521b\u5efa\u6bcf\u4e2a\u7528\u6237\u65f6\uff0c\u5c06\u81ea\u52a8\u521b\u5efa\u4e00\u4e2a\u4e0e\u5176\u540c\u540d\u7684\u57fa\u672c\u7528\u6237\u7ec4\uff0c\u800c\u4e14\u8fd9\u4e2a\u57fa\u672c\u7528\u6237\u7ec4\u53ea\u6709\u8be5\u7528\u6237\u4e00\u4e2a\u4eba\u3002\u5982\u679c\u8be5\u7528\u6237\u4ee5\u540e\u88ab\u5f52\u7eb3\u5230\u5176\u4ed6\u7528\u6237\u7ec4\uff0c\u5219\u8fd9\u4e2a\u5176\u4ed6\u7528\u6237\u7ec4\u79f0\u4e4b\u4e3a\u6269\u5c55\u7528\u6237\u7ec4\u3002\u4e00\u4e2a\u7528\u6237\u53ea\u6709\u4e00\u4e2a\u57fa\u672c\u7528\u6237\u7ec4\uff0c\u4f46\u662f\u53ef\u4ee5\u6709\u591a\u4e2a\u6269\u5c55\u7528\u6237\u7ec4\uff0c\u4ece\u800c\u6ee1\u8db3\u65e5\u5e38\u7684\u5de5\u4f5c\u9700\u8981\u3002<\/p>\n

\n
\n

Tips<\/strong><\/h3>\n<\/div>\n
\n

\u57fa\u672c\u7528\u6237\u7ec4\u5c31\u50cf\u662f\u539f\u751f\u5bb6\u5ead\uff0c\u662f\u5728\u521b\u5efa\u8d26\u53f7\uff08\u51fa\u751f\uff09\u65f6\u5c31\u81ea\u52a8\u751f\u6210\u7684\uff1b\u800c\u6269\u5c55\u7528\u6237\u7ec4\u5219\u50cf\u5de5\u4f5c\u5355\u4f4d\uff0c\u4e3a\u4e86\u5b8c\u6210\u5de5\u4f5c\uff0c\u9700\u8981\u52a0\u5165\u5230\u5404\u4e2a\u4e0d\u540c\u7684\u7fa4\u4f53\u4e2d\uff0c\u8fd9\u662f\u9700\u8981\u624b\u52a8\u6dfb\u52a0\u7684\u3002<\/p>\n<\/div>\n<\/div>\n

1. \u00a0id\u547d\u4ee4<\/strong><\/p>\n

id\u547d\u4ee4\u7528\u4e8e\u663e\u793a\u7528\u6237\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bed\u6cd5\u683c\u5f0f\u4e3a\u201cid\u7528\u6237\u540d\u201d\u3002<\/p>\n

\u8fd9\u4e2aid\u547d\u4ee4\u662f\u4e00\u4e2a\u5728\u521b\u5efa\u7528\u6237\u524d\u9700\u8981\u4ed4\u7ec6\u5b66\u4e60\u7684\u547d\u4ee4\uff0c\u5b83\u80fd\u591f\u7b80\u5355\u8f7b\u677e\u5730\u67e5\u770b\u7528\u6237\u7684\u57fa\u672c\u4fe1\u606f\uff0c\u4f8b\u5982\u7528\u6237ID\u3001\u57fa\u672c\u7ec4\u4e0e\u6269\u5c55\u7ec4GID\uff0c\u4ee5\u4fbf\u4e8e\u6211\u4eec\u5224\u522b\u67d0\u4e2a\u7528\u6237\u662f\u5426\u5df2\u7ecf\u5b58\u5728\uff0c\u4ee5\u53ca\u67e5\u770b\u76f8\u5173\u4fe1\u606f\u3002<\/p>\n

\u4e0b\u9762\u4f7f\u7528id\u547d\u4ee4\u67e5\u770b\u4e00\u4e2a\u540d\u79f0\u4e3alinuxprobe\u7684\u7528\u6237\u4fe1\u606f\uff1a<\/p>\n

[root@linuxprobe ~]# id linuxprobe\r\nuid=1000(linuxprobe) gid=1000(linuxprobe) groups=1000(linuxprobe)<\/pre>\n

2. \u00a0useradd\u547d\u4ee4<\/strong><\/p>\n

useradd\u547d\u4ee4\u7528\u4e8e\u521b\u5efa\u65b0\u7684\u7528\u6237\u8d26\u6237\uff0c\u8bed\u6cd5\u683c\u5f0f\u4e3a\u201cuseradd [\u53c2\u6570]\u00a0\u7528\u6237\u540d\u201d\u3002<\/p>\n

\u53ef\u4ee5\u4f7f\u7528useradd\u547d\u4ee4\u521b\u5efa\u7528\u6237\u8d26\u6237\u3002\u4f7f\u7528\u8be5\u547d\u4ee4\u521b\u5efa\u7528\u6237\u8d26\u6237\u65f6\uff0c\u9ed8\u8ba4\u7684\u7528\u6237\u5bb6\u76ee\u5f55\u4f1a\u88ab\u5b58\u653e\u5728\/home\u76ee\u5f55\u4e2d\uff0c\u9ed8\u8ba4\u7684Shell\u89e3\u91ca\u5668\u4e3a\/bin\/bash\uff0c\u800c\u4e14\u9ed8\u8ba4\u4f1a\u521b\u5efa\u4e00\u4e2a\u4e0e\u8be5\u7528\u6237\u540c\u540d\u7684\u57fa\u672c\u7528\u6237\u7ec4\u3002\u8fd9\u4e9b\u9ed8\u8ba4\u8bbe\u7f6e\u53ef\u4ee5\u6839\u636e\u88685-1\u4e2d\u7684useradd\u547d\u4ee4\u53c2\u6570\u81ea\u884c\u4fee\u6539\u3002<\/p>\n

\u88685-1\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 useradd\u547d\u4ee4\u4e2d\u7684\u53c2\u6570\u4ee5\u53ca\u4f5c\u7528<\/p>\n

\n\n\n\n\n\n\n\n\n\n\n
\u53c2\u6570<\/td>\n\u4f5c\u7528<\/td>\n<\/tr>\n
-d<\/td>\n\u6307\u5b9a\u7528\u6237\u7684\u5bb6\u76ee\u5f55\uff08\u9ed8\u8ba4\u4e3a\/home\/username\uff09<\/td>\n<\/tr>\n
-e<\/td>\n\u8d26\u6237\u7684\u5230\u671f\u65f6\u95f4\uff0c\u683c\u5f0f\u4e3aYYYY-MM-DD.<\/td>\n<\/tr>\n
-u<\/td>\n\u6307\u5b9a\u8be5\u7528\u6237\u7684\u9ed8\u8ba4UID<\/td>\n<\/tr>\n
-g<\/td>\n\u6307\u5b9a\u4e00\u4e2a\u521d\u59cb\u7684\u7528\u6237\u57fa\u672c\u7ec4\uff08\u5fc5\u987b\u5df2\u5b58\u5728\uff09<\/td>\n<\/tr>\n
-G<\/td>\n\u6307\u5b9a\u4e00\u4e2a\u6216\u591a\u4e2a\u6269\u5c55\u7528\u6237\u7ec4<\/td>\n<\/tr>\n
-N<\/td>\n\u4e0d\u521b\u5efa\u4e0e\u7528\u6237\u540c\u540d\u7684\u57fa\u672c\u7528\u6237\u7ec4<\/td>\n<\/tr>\n
-s<\/td>\n\u6307\u5b9a\u8be5\u7528\u6237\u7684\u9ed8\u8ba4Shell\u89e3\u91ca\u5668<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

<\/div>\n

\u4e0b\u9762\u4f7f\u7528useradd\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u540d\u79f0\u4e3alinuxcool\u7684\u7528\u6237\uff0c\u5e76\u4f7f\u7528id\u547d\u4ee4\u786e\u8ba4\u4fe1\u606f\uff1a<\/p>\n

[root@linuxprobe ~]# useradd linuxcool\r\n[root@linuxprobe ~]# id linuxcool\r\nuid=1001(linuxcool) gid=1001(linuxcool) groups=1001(linuxcool)<\/pre>\n

\u4e0b\u9762\u6211\u4eec\u63d0\u9ad8\u96be\u5ea6\uff0c\u521b\u5efa\u4e00\u4e2a\u666e\u901a\u7528\u6237\u5e76\u6307\u5b9a\u5bb6\u76ee\u5f55\u7684\u8def\u5f84\u3001\u7528\u6237\u7684UID\u4ee5\u53caShell\u89e3\u91ca\u5668\u3002\u5728\u4e0b\u9762\u7684\u547d\u4ee4\u4e2d\uff0c\u8bf7\u6ce8\u610f\/sbin\/nologin\uff0c\u5b83\u662f\u7ec8\u7aef\u89e3\u91ca\u5668\u4e2d\u7684\u4e00\u5458\uff0c\u4e0eBash\u89e3\u91ca\u5668\u6709\u7740\u5929\u58e4\u4e4b\u522b\u3002\u4e00\u65e6\u7528\u6237\u7684\u89e3\u91ca\u5668\u88ab\u8bbe\u7f6e\u4e3anologin\uff0c\u5219\u4ee3\u8868\u8be5\u7528\u6237\u4e0d\u80fd\u767b\u5f55\u5230\u7cfb\u7edf\u4e2d\uff1a<\/p>\n

[root@linuxprobe ~]# useradd -d \/home\/linux -u 8888 -s \/sbin\/nologin linuxdown\r\n[root@linuxprobe ~]# id linuxdown\r\nuid=8888(linuxdown) gid=8888(linuxdown) groups=8888(linuxdown)\r\n<\/pre>\n
\n

3. \u00a0groupadd\u547d\u4ee4<\/strong><\/p>\n

groupadd\u547d\u4ee4\u7528\u4e8e\u521b\u5efa\u65b0\u7684\u7528\u6237\u7ec4\uff0c\u8bed\u6cd5\u683c\u5f0f\u4e3a\u201cgroupadd [\u53c2\u6570]\u00a0\u7fa4\u7ec4\u540d\u201d\u3002<\/p>\n

\u4e3a\u4e86\u80fd\u591f\u66f4\u52a0\u9ad8\u6548\u5730\u6307\u6d3e\u7cfb\u7edf\u4e2d\u5404\u4e2a\u7528\u6237\u7684\u6743\u9650\uff0c\u5728\u5de5\u4f5c\u4e2d\u5e38\u5e38\u4f1a\u628a\u51e0\u4e2a\u7528\u6237\u52a0\u5165\u5230\u540c\u4e00\u4e2a\u7ec4\u91cc\u9762\uff0c\u8fd9\u6837\u4fbf\u53ef\u4ee5\u9488\u5bf9\u4e00\u7c7b\u7528\u6237\u7edf\u4e00\u5b89\u6392\u6743\u9650\u3002\u4f8b\u5982\u5728\u5de5\u4f5c\u4e2d\u6210\u7acb\u4e00\u4e2a\u90e8\u95e8\u7ec4\uff0c\u5f53\u6709\u65b0\u7684\u540c\u4e8b\u52a0\u5165\u65f6\u5c31\u628a\u4ed6\u7684\u8d26\u53f7\u6dfb\u52a0\u5230\u8fd9\u4e2a\u90e8\u95e8\u7ec4\u4e2d\uff0c\u8fd9\u6837\u65b0\u540c\u4e8b\u7684\u6743\u9650\u5c31\u81ea\u52a8\u8ddf\u5176\u4ed6\u540c\u4e8b\u4e00\u6a21\u4e00\u6837\u4e86\uff0c\u4ece\u800c\u7701\u53bb\u4e86\u4e00\u7cfb\u5217\u70e6\u7410\u7684\u64cd\u4f5c\u3002<\/p>\n

\u521b\u5efa\u7528\u6237\u7ec4\u7684\u6b65\u9aa4\u975e\u5e38\u7b80\u5355\uff0c\u4f8b\u5982\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u7528\u6237\u7ec4ronny\uff1a<\/p>\n

[root@linuxprobe ~]# groupadd ronny<\/pre>\n<\/div>\n

4. \u00a0usermod\u547d\u4ee4<\/strong><\/p>\n

usermod\u547d\u4ee4\u7528\u4e8e\u4fee\u6539\u7528\u6237\u7684\u5c5e\u6027\uff0c\u82f1\u6587\u5168\u79f0\u4e3a\u201cuser modify\u201d\uff0c\u8bed\u6cd5\u683c\u5f0f\u4e3a\u201cusermod [\u53c2\u6570]\u00a0\u7528\u6237\u540d\u201d\u3002<\/p>\n

\u524d\u6587\u66fe\u53cd\u590d\u5f3a\u8c03\uff0cLinux\u7cfb\u7edf\u4e2d\u7684\u4e00\u5207\u90fd\u662f\u6587\u4ef6\uff0c\u56e0\u6b64\u5728\u7cfb\u7edf\u4e2d\u521b\u5efa\u7528\u6237\u4e5f\u5c31\u662f\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u7684\u8fc7\u7a0b\u3002\u7528\u6237\u7684\u4fe1\u606f\u4fdd\u5b58\u5728\/etc\/passwd\u6587\u4ef6\u4e2d\uff0c\u53ef\u4ee5\u76f4\u63a5\u7528\u6587\u672c\u7f16\u8f91\u5668\u6765\u4fee\u6539\u5176\u4e2d\u7684\u7528\u6237\u53c2\u6570\u9879\u76ee\uff0c\u4e5f\u53ef\u4ee5\u7528usermod\u547d\u4ee4\u4fee\u6539\u5df2\u7ecf\u521b\u5efa\u7684\u7528\u6237\u4fe1\u606f\uff0c\u6bd4\u5982\u7528\u6237\u7684UID\u3001\u57fa\u672c\/\u6269\u5c55\u7528\u6237\u7ec4\u3001\u9ed8\u8ba4\u7ec8\u7aef\u7b49\u3002usermod\u547d\u4ee4\u7684\u53c2\u6570\u4ee5\u53ca\u4f5c\u7528\u5982\u88685-2\u6240\u793a\u3002<\/p>\n

\u88685-2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 usermod\u547d\u4ee4\u4e2d\u7684\u53c2\u6570\u4ee5\u53ca\u4f5c\u7528<\/p>\n\n\n\n\n\n\n\n\n\n\n\n\n
\u53c2\u6570<\/td>\n\u4f5c\u7528<\/td>\n<\/tr>\n
-c<\/td>\n\u586b\u5199\u7528\u6237\u8d26\u6237\u7684\u5907\u6ce8\u4fe1\u606f<\/td>\n<\/tr>\n
-d -m<\/td>\n\u53c2\u6570-m\u4e0e\u53c2\u6570-d\u8fde\u7528\uff0c\u53ef\u91cd\u65b0\u6307\u5b9a\u7528\u6237\u7684\u5bb6\u76ee\u5f55\u5e76\u81ea\u52a8\u628a\u65e7\u7684\u6570\u636e\u8f6c\u79fb\u8fc7\u53bb<\/td>\n<\/tr>\n
-e<\/td>\n\u8d26\u6237\u7684\u5230\u671f\u65f6\u95f4\uff0c\u683c\u5f0f\u4e3aYYYY-MM-DD<\/td>\n<\/tr>\n
-g<\/td>\n\u53d8\u66f4\u6240\u5c5e\u7528\u6237\u7ec4<\/td>\n<\/tr>\n
-G<\/td>\n\u53d8\u66f4\u6269\u5c55\u7528\u6237\u7ec4<\/td>\n<\/tr>\n
-L<\/td>\n\u9501\u5b9a\u7528\u6237\u7981\u6b62\u5176\u767b\u5f55\u7cfb\u7edf<\/td>\n<\/tr>\n
-U<\/td>\n\u89e3\u9501\u7528\u6237\uff0c\u5141\u8bb8\u5176\u767b\u5f55\u7cfb\u7edf<\/td>\n<\/tr>\n
-s<\/td>\n\u53d8\u66f4\u9ed8\u8ba4\u7ec8\u7aef<\/td>\n<\/tr>\n
-u<\/td>\n\u4fee\u6539\u7528\u6237\u7684UID<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

<\/p>\n

\u5927\u5bb6\u4e0d\u8981\u88ab\u8fd9\u4e48\u591a\u53c2\u6570\u5413\u574f\u4e86\u3002\u6211\u4eec\u5148\u6765\u770b\u4e00\u4e0b\u8d26\u6237linuxprobe\u7684\u9ed8\u8ba4\u4fe1\u606f\uff1a<\/p>\n

[root@linuxprobe ~]# id linuxprobe\r\nuid=1000(linuxprobe) gid=1000(linuxprobe) groups=1000(linuxprobe)<\/pre>\n

\u7136\u540e\u5c06\u7528\u6237linuxprobe\u52a0\u5165\u5230root\u7528\u6237\u7ec4\u4e2d\uff0c\u8fd9\u6837\u6269\u5c55\u7ec4\u5217\u8868\u4e2d\u5219\u4f1a\u51fa\u73b0root\u7528\u6237\u7ec4\u7684\u5b57\u6837\uff0c\u800c\u57fa\u672c\u7ec4\u4e0d\u4f1a\u53d7\u5230\u5f71\u54cd\uff1a<\/p>\n

[root@linuxprobe\u00a0~]# usermod -G root linuxprobe\r\n[root@linuxprobe\u00a0~]# id linuxprobe\r\nuid=1000(linuxprobe) gid=1000(linuxprobe) groups=1000(linuxprobe),0(root)<\/strong><\/pre>\n

\u518d\u6765\u8bd5\u8bd5\u7528-u\u53c2\u6570\u4fee\u6539linuxprobe\u7528\u6237\u7684UID\u53f7\u7801\u503c\uff1a<\/p>\n

[root@linuxprobe\u00a0~]# usermod -u 8888 linuxprobe\r\n[root@linuxprobe\u00a0~]# id linuxprobe\r\nuid=8888<\/strong>(linuxprobe) gid=1000(linuxprobe) groups=1000(linuxprobe),0(root)<\/pre>\n

\u9664\u6b64\u4e4b\u5916\uff0c\u540c\u5b66\u4eec\u6700\u5173\u5fc3\u7684\u80af\u5b9a\u662f\u5982\u679c\u628a\u7528\u6237\u7684\u89e3\u91ca\u5668\u7ec8\u7aef\u7531\u9ed8\u8ba4\u7684\/bin\/bash\u4fee\u6539\u4e3a\/sbin\/nologin\u540e\u4f1a\u6709\u4ec0\u4e48\u6837\u7684\u6548\u679c\u5462\uff1f\u6211\u4eec\u6765\u8bd5\u8bd5\u5427\uff1a<\/p>\n

[root@linuxprobe ~]# usermod -s \/sbin\/nologin linuxprobe\r\n[root@linuxprobe ~]# su - linuxprobe\r\nThis account is currently not available.<\/pre>\n

\u6548\u679c\u5f88\u76f4\u89c2\uff01\u5c06\u7528\u6237\u7684\u7ec8\u7aef\u8bbe\u7f6e\u6210\/sbin\/nologin\u540e\u7528\u6237\u9a6c\u4e0a\u5c31\u4e0d\u80fd\u767b\u5f55\u4e86\uff08\u5207\u6362\u8eab\u4efd\u4e5f\u4e0d\u884c\uff09\uff0c\u4f46\u8fd9\u4e2a\u7528\u6237\u4f9d\u7136\u53ef\u4ee5\u88ab\u67d0\u4e2a\u670d\u52a1\u6240\u8c03\u7528\uff0c\u7ba1\u7406\u67d0\u4e2a\u5177\u4f53\u7684\u670d\u52a1\u3002\u8fd9\u6837\u7684\u597d\u5904\u662f\u5f53\u9ed1\u5ba2\u901a\u8fc7\u8fd9\u4e2a\u670d\u52a1\u5165\u4fb5\u6210\u529f\u540e\uff0c\u7834\u574f\u7684\u8303\u56f4\u4e5f\u4ec5\u4ec5\u5c40\u9650\u4e8e\u8fd9\u4e2a\u7279\u5b9a\u7684\u670d\u52a1\uff0c\u800c\u4e0d\u80fd\u4f7f\u7528\u8fd9\u4e2a\u7528\u6237\u8eab\u4efd\u767b\u5f55\u5230\u6574\u53f0\u670d\u52a1\u5668\u4e0a\uff0c\u4ece\u800c\u5c3d\u53ef\u80fd\u5730\u628a\u635f\u5931\u964d\u81f3\u6700\u5c0f\u5316\u3002<\/p>\n

5. \u00a0passwd\u547d\u4ee4<\/strong><\/p>\n

passwd\u547d\u4ee4\u7528\u4e8e\u4fee\u6539\u7528\u6237\u7684\u5bc6\u7801\u3001\u8fc7\u671f\u65f6\u95f4\u7b49\u4fe1\u606f\uff0c\u82f1\u6587\u5168\u79f0\u4e3a\u201cpassword\u201d\uff0c\u8bed\u6cd5\u683c\u5f0f\u4e3a\u201cpasswd [\u53c2\u6570]\u00a0\u7528\u6237\u540d\u201d\u3002<\/p>\n

\u666e\u901a\u7528\u6237\u53ea\u80fd\u4f7f\u7528passwd\u547d\u4ee4\u4fee\u6539\u81ea\u5df1\u7684\u7cfb\u7edf\u5bc6\u7801\uff0c\u800croot\u7ba1\u7406\u5458\u5219\u6709\u6743\u9650\u4fee\u6539\u5176\u4ed6\u6240\u6709\u4eba\u7684\u5bc6\u7801\u3002\u66f4\u9177\u7684\u662f\uff0croot\u7ba1\u7406\u5458\u5728Linux\u7cfb\u7edf\u4e2d\u4fee\u6539\u81ea\u5df1\u6216\u4ed6\u4eba\u7684\u5bc6\u7801\u65f6\u4e0d\u9700\u8981\u9a8c\u8bc1\u65e7\u5bc6\u7801\uff0c\u8fd9\u4e00\u70b9\u7279\u522b\u65b9\u4fbf\u3002\u65e2\u7136root\u7ba1\u7406\u5458\u80fd\u591f\u4fee\u6539\u5176\u4ed6\u7528\u6237\u7684\u5bc6\u7801\uff0c\u5c31\u8868\u793a\u5176\u5b8c\u5168\u62e5\u6709\u8be5\u7528\u6237\u7684\u7ba1\u7406\u6743\u9650\u3002passwd\u547d\u4ee4\u4e2d\u7684\u53c2\u6570\u4ee5\u53ca\u4f5c\u7528\u5982\u88685-3\u6240\u793a\u3002<\/p>\n

\u88685-3\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 passwd\u547d\u4ee4\u4e2d\u7684\u53c2\u6570\u4ee5\u53ca\u4f5c\u7528<\/p>\n

\n\n\n\n\n\n\n\n\n\n
\u53c2\u6570<\/td>\n\u4f5c\u7528<\/td>\n<\/tr>\n
-l<\/td>\n\u9501\u5b9a\u7528\u6237\uff0c\u7981\u6b62\u5176\u767b\u5f55<\/td>\n<\/tr>\n
-u<\/td>\n\u89e3\u9664\u9501\u5b9a\uff0c\u5141\u8bb8\u7528\u6237\u767b\u5f55<\/td>\n<\/tr>\n
--stdin<\/td>\n\u5141\u8bb8\u901a\u8fc7\u6807\u51c6\u8f93\u5165\u4fee\u6539\u7528\u6237\u5bc6\u7801<\/td>\n<\/tr>\n
-d<\/td>\n\u4f7f\u8be5\u7528\u6237\u53ef\u7528\u7a7a\u5bc6\u7801\u767b\u5f55\u7cfb\u7edf<\/td>\n<\/tr>\n
-e<\/td>\n\u5f3a\u5236\u7528\u6237\u5728\u4e0b\u6b21\u767b\u5f55\u65f6\u4fee\u6539\u5bc6\u7801<\/td>\n<\/tr>\n
-S<\/td>\n\u663e\u793a\u7528\u6237\u7684\u5bc6\u7801\u662f\u5426\u88ab\u9501\u5b9a\uff0c\u4ee5\u53ca\u5bc6\u7801\u6240\u91c7\u7528\u7684\u52a0\u5bc6\u7b97\u6cd5\u540d\u79f0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

<\/div>\n

\u8981\u4fee\u6539\u81ea\u5df1\u7684\u5bc6\u7801\uff0c\u53ea\u9700\u8981\u8f93\u5165\u547d\u4ee4\u540e\u6572\u51fb\u56de\u8f66\u952e\u5373\u53ef\uff1a<\/p>\n

[root@linuxprobe ~]# passwd\r\nChanging password for user root.\r\nNew password: \u6b64\u5904\u8f93\u5165\u5bc6\u7801\u503c<\/strong>\r\nRetype new password: \u518d\u6b21\u8f93\u5165\u8fdb\u884c\u786e\u8ba4<\/strong>\r\npasswd: all authentication tokens updated successfully.\r\n<\/pre>\n

\u8981\u4fee\u6539\u5176\u4ed6\u4eba\u7684\u5bc6\u7801\uff0c\u5219\u9700\u8981\u5148\u68c0\u67e5\u5f53\u524d\u662f\u5426\u4e3aroot\u7ba1\u7406\u5458\u6743\u9650\uff0c\u7136\u540e\u5728\u547d\u4ee4\u540e\u6307\u5b9a\u8981\u4fee\u6539\u5bc6\u7801\u7684\u90a3\u4f4d\u7528\u6237\u7684\u540d\u79f0\uff1a<\/p>\n

[root@linuxprobe ~]# passwd linuxprobe\r\nChanging password for user linuxprobe.\r\nNew password:\u6b64\u5904\u8f93\u5165\u5bc6\u7801\u503c\r\n<\/strong>Retype new password: \u518d\u6b21\u8f93\u5165\u8fdb\u884c\u786e\u8ba4<\/strong>\r\npasswd: all authentication tokens updated successfully.<\/pre>\n

\u5047\u8bbe\u60a8\u6709\u4f4d\u540c\u4e8b\u6b63\u5728\u5ea6\u5047\uff0c\u800c\u4e14\u5047\u671f\u5f88\u957f\uff0c\u90a3\u4e48\u53ef\u4ee5\u4f7f\u7528passwd\u547d\u4ee4\u7981\u6b62\u8be5\u7528\u6237\u767b\u5f55\u7cfb\u7edf\uff0c\u7b49\u5047\u671f\u7ed3\u675f\u56de\u5f52\u5de5\u4f5c\u5c97\u4f4d\u65f6\uff0c\u518d\u4f7f\u7528\u8be5\u547d\u4ee4\u5141\u8bb8\u7528\u6237\u767b\u5f55\u7cfb\u7edf\uff0c\u800c\u4e0d\u662f\u5c06\u5176\u5220\u9664\u3002\u8fd9\u6837\u65e2\u4fdd\u8bc1\u4e86\u8fd9\u6bb5\u65f6\u95f4\u5185\u7cfb\u7edf\u7684\u5b89\u5168\uff0c\u4e5f\u907f\u514d\u4e86\u9891\u7e41\u6dfb\u52a0\u3001\u5220\u9664\u7528\u6237\u5e26\u6765\u7684\u9ebb\u70e6\uff1a<\/p>\n

[root@linuxprobe ~]# passwd -l linuxprobe\r\nLocking password for user linuxprobe.\r\npasswd: Success\r\n[root@linuxprobe ~]# passwd -S linuxprobe\r\nlinuxprobe LK 1969-12-31 0 99999 7 -1 (Password locked.<\/strong>)\r\n<\/pre>\n

\u5728\u89e3\u9501\u65f6\uff0c\u8bb0\u5f97\u4e5f\u8981\u4f7f\u7528\u7ba1\u7406\u5458\u7684\u8eab\u4efd\uff1b\u5426\u5219\uff0c\u5982\u679c\u666e\u901a\u7528\u6237\u4e5f\u6709\u9501\u5b9a\u6743\u9650\uff0c\u7cfb\u7edf\u80af\u5b9a\u4f1a\u4e71\u6210\u4e00\u9505\u7ca5\uff1a<\/p>\n

[root@linuxprobe ~]# passwd -u linuxprobe\r\nUnlocking password for user linuxprobe.\r\npasswd: Success\r\n[root@linuxprobe ~]# passwd -S linuxprobe\r\nlinuxprobe PS 1969-12-31 0 99999 7 -1 (Password set, SHA512 crypt.<\/strong>)<\/pre>\n

6. \u00a0userdel\u547d\u4ee4<\/strong><\/p>\n

userdel\u547d\u4ee4\u7528\u4e8e\u5220\u9664\u5df2\u6709\u7684\u7528\u6237\u8d26\u6237\uff0c\u82f1\u6587\u5168\u79f0\u4e3a\u201cuser delete\u201d\uff0c\u8bed\u6cd5\u683c\u5f0f\u4e3a\u201cuserdel [\u53c2\u6570]\u00a0\u7528\u6237\u540d\u201d\u3002<\/p>\n

\u5982\u679c\u786e\u8ba4\u67d0\u4f4d\u7528\u6237\u540e\u7eed\u4e0d\u4f1a\u518d\u767b\u5f55\u5230\u7cfb\u7edf\u4e2d\uff0c\u5219\u53ef\u4ee5\u901a\u8fc7userdel\u547d\u4ee4\u5220\u9664\u8be5\u7528\u6237\u7684\u6240\u6709\u4fe1\u606f\u3002\u5728\u6267\u884c\u5220\u9664\u64cd\u4f5c\u65f6\uff0c\u8be5\u7528\u6237\u7684\u5bb6\u76ee\u5f55\u9ed8\u8ba4\u4f1a\u4fdd\u7559\u4e0b\u6765\uff0c\u6b64\u65f6\u53ef\u4ee5\u4f7f\u7528-r\u53c2\u6570\u5c06\u5176\u5220\u9664\u3002userdel\u547d\u4ee4\u7684\u53c2\u6570\u4ee5\u53ca\u4f5c\u7528\u5982\u88685-4\u6240\u793a\u3002<\/p>\n

\u88685-4\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 userdel\u547d\u4ee4\u4e2d\u7684\u53c2\u6570\u4ee5\u53ca\u4f5c\u7528<\/p>\n\n\n\n\n\n
\u53c2\u6570<\/td>\n\u4f5c\u7528<\/td>\n<\/tr>\n
-f<\/td>\n\u5f3a\u5236\u5220\u9664\u7528\u6237<\/td>\n<\/tr>\n
-r<\/td>\n\u540c\u65f6\u5220\u9664\u7528\u6237\u53ca\u7528\u6237\u5bb6\u76ee\u5f55<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

<\/p>\n

\u5728\u5220\u9664\u4e00\u4e2a\u7528\u6237\u65f6\uff0c\u4e00\u822c\u4f1a\u5efa\u8bae\u4fdd\u7559\u4ed6\u7684\u5bb6\u76ee\u5f55\u6570\u636e\uff0c\u4ee5\u514d\u6709\u91cd\u8981\u7684\u6570\u636e\u88ab\u8bef\u5220\u9664\u3002\u6240\u4ee5\u5728\u4f7f\u7528userdel\u547d\u4ee4\u65f6\u53ef\u4ee5\u4e0d\u52a0\u53c2\u6570\uff0c\u5199\u6e05\u8981\u5220\u9664\u7684\u7528\u6237\u540d\u79f0\u5c31\u884c\uff1a<\/p>\n

[root@linuxprobe ~]# userdel linuxprobe\r\n[root@linuxprobe ~]# id linuxprobe\r\nid: linuxprobe: no such user<\/pre>\n

\u867d\u7136\u6b64\u65f6\u8be5\u7528\u6237\u5df2\u88ab\u5220\u9664\uff0c\u4f46\u5bb6\u76ee\u5f55\u6570\u636e\u4f1a\u7ee7\u7eed\u5b58\u653e\u5728\/home\u76ee\u5f55\u4e2d\uff0c\u7b49\u786e\u8ba4\u672a\u6765\u4e0d\u518d\u4f7f\u7528\u65f6\u5c06\u5176\u624b\u52a8\u5220\u9664\u5373\u53ef\uff1a<\/p>\n

[root@linuxprobe ~]# cd \/home\r\n[root@linuxprobe home]# ls\r\nlinuxprobe linuxcool linuxdown\r\n[root@linuxprobe home]# rm -rf linuxprobe\r\n[root@linuxprobe home]# ls \r\nlinuxcool linuxdown<\/pre>\n
5.2 \u6587\u4ef6\u6743\u9650\u4e0e\u5f52\u5c5e<\/strong><\/span><\/h5>\n

\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u6bcf\u4e2a\u6587\u4ef6\u90fd\u6709\u5f52\u5c5e\u7684\u6240\u6709\u8005\u548c\u6240\u5c5e\u7ec4\uff0c\u5e76\u4e14\u89c4\u5b9a\u4e86\u6587\u4ef6\u7684\u6240\u6709\u8005\u3001\u6240\u5c5e\u7ec4\u4ee5\u53ca\u5176\u4ed6\u4eba\u5bf9\u6587\u4ef6\u6240\u62e5\u6709\u7684\u53ef\u8bfb\uff08r\uff09\u3001\u53ef\u5199\uff08w\uff09\u3001\u53ef\u6267\u884c\uff08x\uff09\u7b49\u6743\u9650\u3002\u5bf9\u4e8e\u4e00\u822c\u6587\u4ef6\u6765\u8bf4\uff0c\u6743\u9650\u6bd4\u8f83\u5bb9\u6613\u7406\u89e3\uff1a\u201c\u53ef\u8bfb\u201d\u8868\u793a\u80fd\u591f\u8bfb\u53d6\u6587\u4ef6\u7684\u5b9e\u9645\u5185\u5bb9\uff1b\u201c\u53ef\u5199\u201d\u8868\u793a\u80fd\u591f\u7f16\u8f91\u3001\u65b0\u589e\u3001\u4fee\u6539\u3001\u5220\u9664\u6587\u4ef6\u7684\u5b9e\u9645\u5185\u5bb9\uff1b\u201c\u53ef\u6267\u884c\u201d\u5219\u8868\u793a\u80fd\u591f\u8fd0\u884c\u4e00\u4e2a\u811a\u672c\u7a0b\u5e8f\u3002\u4f46\u662f\uff0c\u5bf9\u4e8e\u76ee\u5f55\u6587\u4ef6\u6765\u8bf4\uff0c\u7406\u89e3\u5176\u6743\u9650\u8bbe\u7f6e\u5c31\u4e0d\u90a3\u4e48\u5bb9\u6613\u4e86\u3002\u5f88\u591a\u8d44\u6df1Linux\u7528\u6237\u5176\u5b9e\u4e5f\u6ca1\u6709\u771f\u6b63\u641e\u660e\u767d\u3002\u5bf9\u4e8e\u76ee\u5f55\u6587\u4ef6\u6765\u8bf4\uff0c\u201c\u53ef\u8bfb\u201d\u8868\u793a\u80fd\u591f\u8bfb\u53d6\u76ee\u5f55\u5185\u7684\u6587\u4ef6\u5217\u8868\uff1b\u201c\u53ef\u5199\u201d\u8868\u793a\u80fd\u591f\u5728\u76ee\u5f55\u5185\u65b0\u589e\u3001\u5220\u9664\u3001\u91cd\u547d\u540d\u6587\u4ef6\uff1b\u800c\u201c\u53ef\u6267\u884c\u201d\u5219\u8868\u793a\u80fd\u591f\u8fdb\u5165\u8be5\u76ee\u5f55\u3002<\/p>\n

\u53ef\u8bfb\u3001\u53ef\u5199\u3001\u53ef\u6267\u884c\u6743\u9650\u5bf9\u5e94\u7684\u547d\u4ee4\u5728\u6587\u4ef6\u548c\u76ee\u5f55\u4e0a\u662f\u6709\u533a\u522b\u7684\uff0c\u5177\u4f53\u53ef\u53c2\u8003\u88685-5\u3002<\/p>\n

\u88685-5\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u8bfb\u5199\u6267\u884c\u6743\u9650\u5bf9\u4e8e\u6587\u4ef6\u4e0e\u76ee\u5f55\u53ef\u6267\u884c\u547d\u4ee4\u7684\u533a\u522b<\/p>\n

\"\"<\/p>\n

\u6587\u4ef6\u7684\u53ef\u8bfb\u3001\u53ef\u5199\u3001\u53ef\u6267\u884c\u6743\u9650\u7684\u82f1\u6587\u5168\u79f0\u5206\u522b\u662fread\u3001write\u3001execute\uff0c\u53ef\u4ee5\u7b80\u5199\u4e3ar\u3001w\u3001x\uff0c\u4ea6\u53ef\u5206\u522b\u7528\u6570\u5b574\u30012\u30011\u6765\u8868\u793a\uff0c\u6587\u4ef6\u6240\u6709\u8005\u3001\u6587\u4ef6\u6240\u5c5e\u7ec4\u53ca\u5176\u4ed6\u7528\u6237\u6743\u9650\u4e4b\u95f4\u65e0\u5173\u8054\uff0c\u5982\u88685-6\u6240\u793a\u3002<\/p>\n

\u88685-6\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u6587\u4ef6\u6743\u9650\u7684\u5b57\u7b26\u4e0e\u6570\u5b57\u8868\u793a<\/p>\n

\"\"<\/p>\n

\u6587\u4ef6\u6743\u9650\u7684\u6570\u5b57\u8868\u793a\u6cd5\u57fa\u4e8e\u5b57\u7b26\uff08rwx\uff09\u7684\u6743\u9650\u8ba1\u7b97\u800c\u6765\uff0c\u5176\u76ee\u7684\u662f\u7b80\u5316\u6743\u9650\u7684\u8868\u793a\u65b9\u5f0f\u3002\u4f8b\u5982\uff0c\u82e5\u67d0\u4e2a\u6587\u4ef6\u7684\u6743\u9650\u4e3a7\uff0c\u5219\u4ee3\u8868\u53ef\u8bfb\u3001\u53ef\u5199\u3001\u53ef\u6267\u884c\uff084+2+1\uff09\uff1b\u82e5\u6743\u9650\u4e3a6\uff0c\u5219\u4ee3\u8868\u53ef\u8bfb\u3001\u53ef\u5199\uff084+2\uff09\u3002\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u4f8b\u5b50\u3002\u73b0\u5728\u6709\u8fd9\u6837\u4e00\u4e2a\u6587\u4ef6\uff0c\u5176\u6240\u6709\u8005\u62e5\u6709\u53ef\u8bfb\u3001\u53ef\u5199\u3001\u53ef\u6267\u884c\u7684\u6743\u9650\uff0c\u5176\u6587\u4ef6\u6240\u5c5e\u7ec4\u62e5\u6709\u53ef\u8bfb\u3001\u53ef\u5199\u7684\u6743\u9650\uff1b\u5176\u4ed6\u4eba\u53ea\u6709\u53ef\u8bfb\u7684\u6743\u9650\u3002\u90a3\u4e48\uff0c\u8fd9\u4e2a\u6587\u4ef6\u7684\u6743\u9650\u5c31\u662frwxrw-r--\uff0c\u6570\u5b57\u6cd5\u8868\u793a\u5373\u4e3a764\u3002\u4e0d\u8fc7\u5927\u5bb6\u5343\u4e07\u522b\u518d\u5c06\u8fd93\u4e2a\u6570\u5b57\u76f8\u52a0\uff0c\u8ba1\u7b97\u51fa7+6+4=17\u7684\u7ed3\u679c\uff0c\u8fd9\u662f\u5c0f\u5b66\u7684\u6570\u5b66\u52a0\u51cf\u6cd5\uff0c\u4e0d\u662fLinux\u7cfb\u7edf\u7684\u6743\u9650\u6570\u5b57\u8868\u793a\u6cd5\uff0c\u4e09\u8005\u4e4b\u95f4\u6ca1\u6709\u4e92\u901a\u5173\u7cfb\u3002<\/p>\n

\u8fd9\u91cc\u4ee5rw-r-x-w-\u6743\u9650\u4e3a\u4f8b\u6765\u4ecb\u7ecd\u5982\u4f55\u5c06\u5b57\u7b26\u8868\u793a\u7684\u6743\u9650\u8f6c\u6362\u4e3a\u6570\u5b57\u8868\u793a\u7684\u6743\u9650\u3002\u9996\u5148\uff0c\u8981\u5c06\u5404\u4e2a\u4f4d\u4e0a\u7684\u5b57\u7b26\u66ff\u6362\u4e3a\u6570\u5b57\uff0c\u5982\u56fe5-1\u6240\u793a\u3002<\/p>\n

\u51cf\u53f7\u662f\u5360\u4f4d\u7b26\uff0c\u4ee3\u8868\u8fd9\u91cc\u6ca1\u6709\u6743\u9650\uff0c\u5728\u6570\u5b57\u8868\u793a\u6cd5\u4e2d\u75280\u8868\u793a\u3002\u4e5f\u5c31\u662f\u8bf4\uff0crw-\u8f6c\u6362\u540e\u662f420\uff0cr-x\u8f6c\u6362\u540e\u662f401\uff0c-w-\u8f6c\u6362\u540e\u662f020\u3002\u7136\u540e\uff0c\u5c06\u8fd93\u7ec4\u6570\u5b57\u4e4b\u95f4\u7684\u6bcf\u7ec4\u6570\u5b57\u8fdb\u884c\u76f8\u52a0\uff0c\u5f97\u51fa652\uff0c\u8fd9\u4fbf\u662f\u8f6c\u6362\u540e\u7684\u6570\u5b57\u8868\u793a\u6743\u9650\u3002<\/p>\n

\u5c06\u6570\u5b57\u8868\u793a\u6743\u9650\u8f6c\u6362\u56de\u5b57\u6bcd\u8868\u793a\u6743\u9650\u7684\u96be\u5ea6\u76f8\u5bf9\u6765\u8bf4\u5c31\u5927\u4e00\u4e9b\u4e86\uff0c\u8fd9\u91cc\u4ee5652\u6743\u9650\u4e3a\u4f8b\u8fdb\u884c\u8bb2\u89e3\u3002\u9996\u5148\uff0c\u6570\u5b576\u662f\u75314+2\u5f97\u5230\u7684\uff0c\u4e0d\u53ef\u80fd\u662f4+1+1\uff08\u56e0\u4e3a\u6bcf\u4e2a\u6743\u9650\u53ea\u4f1a\u51fa\u73b0\u4e00\u6b21\uff0c\u4e0d\u53ef\u80fd\u540c\u65f6\u6709\u4e24\u4e2ax\u6267\u884c\u6743\u9650\uff09\uff1b\u6570\u5b575\u5219\u662f4+1\u5f97\u5230\u7684\uff1b\u6570\u5b572\u662f\u672c\u8eab\uff0c\u6ca1\u6709\u6743\u9650\u5373\u662f\u7a7a\u503c0\u3002\u63a5\u4e0b\u6765\u6309\u7167\u88685-6\u6240\u793a\u7684\u683c\u5f0f\u8fdb\u884c\u4e66\u5199\uff0c\u5f97\u5230420401020\u8fd9\u6837\u4e00\u4e32\u6570\u5b57\u3002\u6709\u4e86\u8fd9\u4e9b\u4fe1\u606f\u5c31\u597d\u529e\u4e86\uff0c\u5c31\u53ef\u4ee5\u628a\u8fd9\u4e32\u6570\u5b57\u8f6c\u6362\u6210\u5b57\u6bcd\u4e86\uff0c\u5982\u56fe5-2\u6240\u793a\u3002<\/p>\n

\u5927\u5bb6\u4e00\u5b9a\u8981\u5fc3\u4e2d\u7262\u8bb0\uff0c\u6587\u4ef6\u7684\u6240\u6709\u8005\u3001\u6240\u5c5e\u7ec4\u548c\u5176\u4ed6\u7528\u6237\u7684\u6743\u9650\u4e4b\u95f4\u65e0\u5173\u8054\u3002\u4e00\u5b9a\u4e0d\u8981\u5199\u6210rrwwx----\u7684\u6837\u5b50\uff0c\u4e00\u5b9a\u8981\u628arwx\u6743\u9650\u4f4d\u5bf9\u5e94\u5230\u6b63\u786e\u7684\u4f4d\u7f6e\uff0c\u5199\u6210rw-r-x-w-\u3002<\/p>\n

\"\"<\/p>\n

\u56fe5-1 \u5b57\u7b26\u4e0e\u6570\u5b57\u6743\u9650\u8f6c\u6362\u793a\u610f\u56fe<\/p>\n

\"\"<\/p>\n

\u56fe5-2 \u6570\u5b57\u4e0e\u5b57\u7b26\u6743\u9650\u8f6c\u6362\u793a\u610f\u56fe<\/p>\n

Linux\u7cfb\u7edf\u7684\u6587\u4ef6\u6743\u9650\u76f8\u5f53\u590d\u6742\uff0c\u4f46\u662f\u7528\u9014\u5f88\u5e7f\u6cdb\uff0c\u5efa\u8bae\u5927\u5bb6\u628a\u5b83\u5f7b\u5e95\u641e\u6e05\u695a\u4e4b\u540e\u518d\u5b66\u4e60\u4e0b\u4e00\u8282\u7684\u5185\u5bb9\u3002\u73b0\u5728\u6765\u7ec3\u4e60\u4e00\u4e0b\u3002\u8bf7\u5404\u4f4d\u8bfb\u8005\u5206\u522b\u8ba1\u7b97\u6570\u5b57\u8868\u793a\u6cd5764\u3001652\u3001153\u3001731\u6240\u5bf9\u5e94\u7684\u5b57\u7b26\u8868\u793a\u6cd5\uff0c\u7136\u540e\u518d\u628arwxrw-r--\u3001rw--w--wx\u3001rw-r--r--\u8f6c\u6362\u6210\u6570\u5b57\u8868\u793a\u6cd5\u3002<\/p>\n

\u4e0b\u9762\u6211\u4eec\u5229\u7528\u4e0a\u6587\u8bb2\u89e3\u7684\u77e5\u8bc6\uff0c\u4e00\u8d77\u5206\u6790\u56fe5-3\u4e2d\u6240\u793a\u7684\u6587\u4ef6\u4fe1\u606f\u3002<\/p>\n

\"\u6587\u4ef6\u6743\u9650\"<\/p>\n

\u56fe5-3 \u901a\u8fc7ls\u547d\u4ee4\u67e5\u770b\u5230\u7684\u6587\u4ef6\u5c5e\u6027\u4fe1\u606f<\/p>\n

\u5728\u56fe5-3\u4e2d\uff0c\u5305\u542b\u4e86\u6587\u4ef6\u7684\u7c7b\u578b\u3001\u8bbf\u95ee\u6743\u9650\u3001\u6240\u6709\u8005\uff08\u5c5e\u4e3b\uff09\u3001\u6240\u5c5e\u7ec4\uff08\u5c5e\u7ec4\uff09\u3001\u5360\u7528\u7684\u78c1\u76d8\u5927\u5c0f\u3001\u6700\u540e\u4fee\u6539\u65f6\u95f4\u548c\u6587\u4ef6\u540d\u79f0\u7b49\u4fe1\u606f\u3002\u901a\u8fc7\u5206\u6790\u53ef\u77e5\uff0c\u8be5\u6587\u4ef6\u7684\u7c7b\u578b\u4e3a\u666e\u901a\u6587\u4ef6\uff0c\u6240\u6709\u8005\u6743\u9650\u4e3a\u53ef\u8bfb\u3001\u53ef\u5199\uff08rw-\uff09\uff0c\u6240\u5c5e\u7ec4\u6743\u9650\u4e3a\u53ef\u8bfb\uff08r--\uff09\uff0c\u9664\u6b64\u4ee5\u5916\u7684\u5176\u4ed6\u4eba\u4e5f\u53ea\u6709\u53ef\u8bfb\u6743\u9650\uff08r--\uff09\uff0c\u6587\u4ef6\u7684\u78c1\u76d8\u5360\u7528\u5927\u5c0f\u662f34298\u5b57\u8282\uff0c\u6700\u8fd1\u4e00\u6b21\u7684\u4fee\u6539\u65f6\u95f4\u4e3a4\u67082\u65e5\u76840:23\uff0c\u6587\u4ef6\u7684\u540d\u79f0\u4e3ainstall.log\u3002<\/p>\n

\u6392\u5728\u6743\u9650\u524d\u9762\u7684\u51cf\u53f7\uff08-\uff09\u662f\u6587\u4ef6\u7c7b\u578b\uff08\u51cf\u53f7\u8868\u793a\u666e\u901a\u6587\u4ef6\uff09\uff0c\u65b0\u624b\u7ecf\u5e38\u4f1a\u628a\u5b83\u8ddf\u201c\u65e0\u6743\u9650\u201d\u6df7\u6dc6\u3002\u5c3d\u7ba1\u5728Linux\u7cfb\u7edf\u4e2d\u4e00\u5207\u90fd\u662f\u6587\u4ef6\uff0c\u4f46\u662f\u4e0d\u540c\u7684\u6587\u4ef6\u7531\u4e8e\u4f5c\u7528\u4e0d\u540c\uff0c\u56e0\u6b64\u7c7b\u578b\u4e5f\u4e0d\u5c3d\u76f8\u540c\uff08\u6709\u4e00\u70b9\u50cfWindows\u7cfb\u7edf\u7684\u540e\u7f00\u540d\uff09\u3002\u5e38\u89c1\u7684\u6587\u4ef6\u7c7b\u578b\u5305\u62ec\u666e\u901a\u6587\u4ef6\uff08-\uff09\u3001\u76ee\u5f55\u6587\u4ef6\uff08d\uff09\u3001\u94fe\u63a5\u6587\u4ef6\uff08l\uff09\u3001\u7ba1\u9053\u6587\u4ef6\uff08p\uff09\u3001\u5757\u8bbe\u5907\u6587\u4ef6\uff08b\uff09\u4ee5\u53ca\u5b57\u7b26\u8bbe\u5907\u6587\u4ef6\uff08c\uff09\u3002<\/p>\n

\u666e\u901a\u6587\u4ef6\u7684\u8303\u56f4\u7279\u522b\u5e7f\u6cdb\uff0c\u6bd4\u5982\u7eaf\u6587\u672c\u4fe1\u606f\u3001\u670d\u52a1\u914d\u7f6e\u4fe1\u606f\u3001\u65e5\u5fd7\u4fe1\u606f\u4ee5\u53caShell\u811a\u672c<\/a>\u7b49\uff0c\u90fd\u5c5e\u4e8e\u666e\u901a\u6587\u4ef6\u3002\u51e0\u4e4e\u5728\u6bcf\u4e2a\u76ee\u5f55\u4e0b\u90fd\u80fd\u770b\u5230\u666e\u901a\u6587\u4ef6\uff08-\uff09\u548c\u76ee\u5f55\u6587\u4ef6\uff08d\uff09\u7684\u8eab\u5f71\u3002\u5757\u8bbe\u5907\u6587\u4ef6\uff08b\uff09\u548c\u5b57\u7b26\u8bbe\u5907\u6587\u4ef6\uff08c\uff09\u4e00\u822c\u662f\u6307\u786c\u4ef6\u8bbe\u5907\uff0c\u6bd4\u5982\u9f20\u6807\u3001\u952e\u76d8\u3001\u5149\u9a71\u3001\u786c\u76d8\u7b49\uff0c\u5728\/dev\/\u76ee\u5f55\u4e2d\u6700\u4e3a\u5e38\u89c1\u3002\u5e94\u8be5\u5f88\u5c11\u6709\u4eba\u4f1a\u5bf9\u9f20\u6807\u3001\u952e\u76d8\u8fdb\u884c\u786c\u4ef6\u7ea7\u522b\u7684\u7ba1\u7406\u5427\u3002<\/p>\n

5.3 \u6587\u4ef6\u7684\u7279\u6b8a\u6743\u9650<\/span><\/strong><\/h5>\n

\u5728\u590d\u6742\u591a\u53d8\u7684\u751f\u4ea7\u73af\u5883\u4e2d\uff0c\u5355\u7eaf\u8bbe\u7f6e\u6587\u4ef6\u7684rwx\u6743\u9650\u65e0\u6cd5\u6ee1\u8db3\u6211\u4eec\u5bf9\u5b89\u5168\u548c\u7075\u6d3b\u6027\u7684\u9700\u6c42\uff0c\u56e0\u6b64\u4fbf\u6709\u4e86SUID\u3001SGID\u4e0eSBIT\u7684\u7279\u6b8a\u6743\u9650\u4f4d\u3002\u8fd9\u662f\u4e00\u79cd\u5bf9\u6587\u4ef6\u6743\u9650\u8fdb\u884c\u8bbe\u7f6e\u7684\u7279\u6b8a\u529f\u80fd\uff0c\u53ef\u4ee5\u4e0e\u4e00\u822c\u6743\u9650\u540c\u65f6\u4f7f\u7528\uff0c\u4ee5\u5f25\u8865\u4e00\u822c\u6743\u9650\u4e0d\u80fd\u5b9e\u73b0\u7684\u529f\u80fd\u3002<\/p>\n

\u4e0b\u9762\u5177\u4f53\u89e3\u91ca\u8fd93\u4e2a\u7279\u6b8a\u6743\u9650\u4f4d\u7684\u529f\u80fd\u4ee5\u53ca\u7528\u6cd5\u3002<\/p>\n

1. \u00a0SUID<\/strong><\/p>\n

SUID\u662f\u4e00\u79cd\u5bf9\u4e8c\u8fdb\u5236\u7a0b\u5e8f\u8fdb\u884c\u8bbe\u7f6e\u7684\u7279\u6b8a\u6743\u9650\uff0c\u80fd\u591f\u8ba9\u4e8c\u8fdb\u5236\u7a0b\u5e8f\u7684\u6267\u884c\u8005\u4e34\u65f6\u62e5\u6709\u6240\u6709\u8005\u7684\u6743\u9650\uff08\u4ec5\u5bf9\u62e5\u6709\u6267\u884c\u6743\u9650\u7684\u4e8c\u8fdb\u5236\u7a0b\u5e8f\u6709\u6548\uff09\u3002\u4f8b\u5982\uff0c\u6240\u6709\u7528\u6237\u90fd\u53ef\u4ee5\u6267\u884cpasswd\u547d\u4ee4\u6765\u4fee\u6539\u81ea\u5df1\u7684\u7528\u6237\u5bc6\u7801\uff0c\u800c\u7528\u6237\u5bc6\u7801\u4fdd\u5b58\u5728\/etc\/shadow\u6587\u4ef6\u4e2d\u3002\u4ed4\u7ec6\u67e5\u770b\u8fd9\u4e2a\u6587\u4ef6\u5c31\u4f1a\u53d1\u73b0\u5b83\u7684\u9ed8\u8ba4\u6743\u9650\u662f000\uff0c\u4e5f\u5c31\u662f\u8bf4\u9664\u4e86root\u7ba1\u7406\u5458\u4ee5\u5916\uff0c\u6240\u6709\u7528\u6237\u90fd\u6ca1\u6709\u67e5\u770b\u6216\u7f16\u8f91\u8be5\u6587\u4ef6\u7684\u6743\u9650\u3002\u4f46\u662f\uff0c\u5728\u4f7f\u7528passwd\u547d\u4ee4\u65f6\u5982\u679c\u52a0\u4e0aSUID\u7279\u6b8a\u6743\u9650\u4f4d\uff0c\u5c31\u53ef\u8ba9\u666e\u901a\u7528\u6237\u4e34\u65f6\u83b7\u5f97\u7a0b\u5e8f\u6240\u6709\u8005\u7684\u8eab\u4efd\uff0c\u628a\u53d8\u66f4\u7684\u5bc6\u7801\u4fe1\u606f\u5199\u5165\u5230shadow\u6587\u4ef6\u4e2d\u3002\u8fd9\u5f88\u50cf\u5728\u53e4\u88c5\u5267\u4e2d\u89c1\u5230\u7684\u624b\u6301\u5c1a\u65b9\u5b9d\u5251\u7684\u94a6\u5dee\u5927\u81e3\uff0c\u4ed6\u624b\u6301\u7684\u5c1a\u65b9\u5b9d\u5251\u4ee3\u8868\u7684\u662f\u7687\u4e0a\u7684\u6743\u5a01\uff0c\u56e0\u6b64\u53ef\u4ee5\u60e9\u6212\u8d2a\u5b98\uff0c\u4f46\u8fd9\u5e76\u4e0d\u610f\u5473\u7740\u4ed6\u6c38\u4e45\u6210\u4e3a\u4e86\u7687\u4e0a\u3002\u56e0\u6b64\u8fd9\u53ea\u662f\u4e00\u79cd\u6709\u6761\u4ef6\u7684\u3001\u4e34\u65f6\u7684\u7279\u6b8a\u6743\u9650\u6388\u6743\u65b9\u6cd5\u3002<\/p>\n

\u67e5\u770bpasswd\u547d\u4ee4\u5c5e\u6027\u65f6\u53d1\u73b0\u6240\u6709\u8005\u7684\u6743\u9650\u7531rwx\u53d8\u6210\u4e86rws\uff0c\u5176\u4e2dx\u6539\u53d8\u6210s\u5c31\u610f\u5473\u7740\u8be5\u6587\u4ef6\u88ab\u8d4b\u4e88\u4e86SUID\u6743\u9650\u3002\u53e6\u5916\u6709\u8bfb\u8005\u4f1a\u597d\u5947\uff0c\u90a3\u4e48\u5982\u679c\u539f\u672c\u7684\u6743\u9650\u662frw-\u5462\uff1f\u5982\u679c\u539f\u5148\u6743\u9650\u4f4d\u4e0a\u6ca1\u6709x\u6267\u884c\u6743\u9650\uff0c\u90a3\u4e48\u88ab\u8d4b\u4e88\u7279\u6b8a\u6743\u9650\u540e\u5c06\u53d8\u6210\u5927\u5199\u7684S\u3002<\/p>\n

[root@linuxprobe ~]# ls -l \/etc\/shadow\r\n----------<\/strong>. 1 root root 1312 Jul 21 05:08 \/etc\/shadow\r\n[root@linuxprobe ~]# ls -l \/bin\/passwd \r\n-rws<\/strong>r-xr-x. 1 root root 34512 Aug 13 2018 \/bin\/passwd<\/span><\/pre>\n
\n
\n

Tips<\/strong><\/h3>\n<\/div>\n
\n

\u52a0\u7c97\u663e\u793a\u7684\u5b57\u4f53\u7528\u6765\u544a\u8beb\u7528\u6237\u4e00\u5b9a\u8981\u5c0f\u5fc3\u8fd9\u4e2a\u6743\u9650\uff0c\u56e0\u4e3a\u4e00\u65e6\u67d0\u4e2a\u547d\u4ee4\u6587\u4ef6\u88ab\u8bbe\u7f6e\u4e86SUID\u6743\u9650\uff0c\u5c31\u610f\u5473\u7740\u51e1\u662f\u6267\u884c\u8be5\u6587\u4ef6\u7684\u4eba\u90fd\u53ef\u4ee5\u4e34\u65f6\u83b7\u53d6\u5230\u6587\u4ef6\u6240\u6709\u8005\u6240\u5bf9\u5e94\u7684\u66f4\u9ad8\u6743\u9650\u3002\u56e0\u6b64\uff0c\u5343\u4e07\u4e0d\u8981\u5c06SUID\u6743\u9650\u8bbe\u7f6e\u5230vim\u3001cat\u3001rm\u7b49\u547d\u4ee4\u4e0a\u9762\uff01\uff01\uff01<\/p>\n<\/div>\n<\/div>\n

2. \u00a0SGID<\/strong><\/p>\n

SGID\u7279\u6b8a\u6743\u9650\u6709\u4e24\u79cd\u5e94\u7528\u573a\u666f\uff1a\u5f53\u5bf9\u4e8c\u8fdb\u5236\u7a0b\u5e8f\u8fdb\u884c\u8bbe\u7f6e\u65f6\uff0c\u80fd\u591f\u8ba9\u6267\u884c\u8005\u4e34\u65f6\u83b7\u53d6\u6587\u4ef6\u6240\u5c5e\u7ec4\u7684\u6743\u9650\uff1b\u5f53\u5bf9\u76ee\u5f55\u8fdb\u884c\u8bbe\u7f6e\u65f6\uff0c\u5219\u662f\u8ba9\u76ee\u5f55\u5185\u65b0\u521b\u5efa\u7684\u6587\u4ef6\u81ea\u52a8\u7ee7\u627f\u8be5\u76ee\u5f55\u539f\u6709\u7528\u6237\u7ec4\u7684\u540d\u79f0\u3002<\/p>\n

SGID\u7684\u7b2c\u4e00\u79cd\u529f\u80fd\u662f\u53c2\u8003SUID\u800c\u8bbe\u8ba1\u7684\uff0c\u4e0d\u540c\u70b9\u5728\u4e8e\u6267\u884c\u7a0b\u5e8f\u7684\u7528\u6237\u83b7\u53d6\u7684\u4e0d\u518d\u662f\u6587\u4ef6\u6240\u6709\u8005\u7684\u4e34\u65f6\u6743\u9650\uff0c\u800c\u662f\u83b7\u53d6\u5230\u6587\u4ef6\u6240\u5c5e\u7ec4\u7684\u6743\u9650\u3002\u4e3e\u4f8b\u6765\u8bf4\uff0c\u5728\u65e9\u671f\u7684Linux\u7cfb\u7edf\u4e2d\uff0c\/dev\/kmem\u662f\u4e00\u4e2a\u5b57\u7b26\u8bbe\u5907\u6587\u4ef6\uff0c\u7528\u4e8e\u5b58\u50a8\u5185\u6838\u7a0b\u5e8f\u8981\u8bbf\u95ee\u7684\u6570\u636e\uff0c\u6743\u9650\u4e3a\uff1a<\/p>\n

cr--r-----<\/strong>\u00a0\u00a0 1 root system 2,\u00a0 1 Feb 11 2017 \u00a0kmem<\/p><\/blockquote>\n

\u5927\u5bb6\u770b\u51fa\u95ee\u9898\u4e86\u5417\uff1f\u9664\u4e86root\u7ba1\u7406\u5458\u6216\u5c5e\u4e8esystem\u7ec4\u7684\u6210\u5458\u5916\uff0c\u6240\u6709\u7528\u6237\u90fd\u6ca1\u6709\u8bfb\u53d6\u8be5\u6587\u4ef6\u7684\u6743\u9650\u3002\u7531\u4e8e\u5728\u5e73\u65f6\u9700\u8981\u67e5\u770b\u7cfb\u7edf\u7684\u8fdb\u7a0b\u72b6\u6001\uff0c\u4e3a\u4e86\u80fd\u591f\u83b7\u53d6\u8fdb\u7a0b\u7684\u72b6\u6001\u4fe1\u606f\uff0c\u53ef\u5728\u7528\u4e8e\u67e5\u770b\u7cfb\u7edf\u8fdb\u7a0b\u72b6\u6001\u7684ps\u547d\u4ee4\u6587\u4ef6\u4e0a\u589e\u52a0SGID\u7279\u6b8a\u6743\u9650\u4f4d\u3002\u4e0b\u9762\u67e5\u770bps\u547d\u4ee4\u6587\u4ef6\u7684\u5c5e\u6027\u4fe1\u606f\uff1a<\/p>\n

-r-xr-s<\/strong>r-x\u00a0\u00a0 1 bin system 59346 Feb 11\u00a02017 \u00a0ps<\/p><\/blockquote>\n

\u8fd9\u6837\u4e00\u6765\uff0c\u7531\u4e8eps\u547d\u4ee4\u88ab\u589e\u52a0\u4e86SGID\u7279\u6b8a\u6743\u9650\u4f4d\uff0c\u6240\u4ee5\u5f53\u7528\u6237\u6267\u884c\u8be5\u547d\u4ee4\u65f6\uff0c\u4e5f\u5c31\u4e34\u65f6\u83b7\u53d6\u5230\u4e86system\u7528\u6237\u7ec4\u7684\u6743\u9650\uff0c\u4ece\u800c\u987a\u5229\u5730\u8bfb\u53d6\u5230\u4e86\u8bbe\u5907\u6587\u4ef6\u3002<\/p>\n

\u524d\u6587\u63d0\u5230\uff0c\u6bcf\u4e2a\u6587\u4ef6\u90fd\u6709\u5176\u5f52\u5c5e\u7684\u6240\u6709\u8005\u548c\u6240\u5c5e\u7ec4\uff0c\u5f53\u521b\u5efa\u6216\u4f20\u9001\u4e00\u4e2a\u6587\u4ef6\u540e\uff0c\u8fd9\u4e2a\u6587\u4ef6\u5c31\u4f1a\u81ea\u52a8\u5f52\u5c5e\u4e8e\u6267\u884c\u8fd9\u4e2a\u64cd\u4f5c\u7684\u7528\u6237\uff08\u5373\u8be5\u7528\u6237\u662f\u6587\u4ef6\u7684\u6240\u6709\u8005\uff09\u3002\u5982\u679c\u73b0\u5728\u9700\u8981\u5728\u4e00\u4e2a\u90e8\u95e8\u5185\u8bbe\u7f6e\u5171\u4eab\u76ee\u5f55\uff0c\u8ba9\u90e8\u95e8\u5185\u7684\u6240\u6709\u4eba\u5458\u90fd\u80fd\u591f\u8bfb\u53d6\u76ee\u5f55\u4e2d\u7684\u5185\u5bb9\uff0c\u90a3\u4e48\u5c31\u53ef\u4ee5\u5728\u521b\u5efa\u90e8\u95e8\u5171\u4eab\u76ee\u5f55\u540e\uff0c\u5728\u8be5\u76ee\u5f55\u4e0a\u8bbe\u7f6eSGID\u7279\u6b8a\u6743\u9650\u4f4d\u3002\u8fd9\u6837\uff0c\u90e8\u95e8\u5185\u7684\u4efb\u4f55\u4eba\u5458\u5728\u91cc\u9762\u521b\u5efa\u7684\u4efb\u4f55\u6587\u4ef6\u90fd\u4f1a\u5f52\u5c5e\u4e8e\u8be5\u76ee\u5f55\u7684\u6240\u5c5e\u7ec4\uff0c\u800c\u4e0d\u518d\u662f\u81ea\u5df1\u7684\u57fa\u672c\u7528\u6237\u7ec4\u3002\u6b64\u65f6\uff0c\u7528\u5230\u7684\u5c31\u662fSGID\u7684\u7b2c\u4e8c\u4e2a\u529f\u80fd\uff0c\u5373\u5728\u67d0\u4e2a\u76ee\u5f55\u4e2d\u521b\u5efa\u7684\u6587\u4ef6\u81ea\u52a8\u7ee7\u627f\u8be5\u76ee\u5f55\u7684\u7528\u6237\u7ec4\uff08\u53ea\u53ef\u4ee5\u5bf9\u76ee\u5f55\u8fdb\u884c\u8bbe\u7f6e\uff09\u3002<\/p>\n

[root@linuxprobe ~]# cd \/tmp\r\n[root@linuxprobe tmp]# mkdir testdir\r\n[root@linuxprobe tmp]# ls -ald testdir\r\ndrwxr-xr-x. 2 root root 6 Oct 27 23:44 testdir\r\n[root@linuxprobe tmp]# chmod -R 777 testdir\r\n[root@linuxprobe tmp]# chmod -R g+s testdir\r\n[root@linuxprobe tmp]# ls -ald testdir\r\ndrwxrwsrwx<\/strong>. 2 root root 6 Oct 27 23:44 testdir\r\n<\/pre>\n

\u5728\u4f7f\u7528\u4e0a\u8ff0\u547d\u4ee4\u8bbe\u7f6e\u597d\u76ee\u5f55\u7684777\u6743\u9650\uff08\u786e\u4fdd\u666e\u901a\u7528\u6237\u53ef\u4ee5\u5411\u5176\u4e2d\u5199\u5165\u6587\u4ef6\uff09\uff0c\u5e76\u4e3a\u8be5\u76ee\u5f55\u8bbe\u7f6e\u4e86SGID\u7279\u6b8a\u6743\u9650\u4f4d\u540e\uff0c\u5c31\u53ef\u4ee5\u5207\u6362\u81f3\u4e00\u4e2a\u666e\u901a\u7528\u6237\uff0c\u7136\u540e\u5c1d\u8bd5\u5728\u8be5\u76ee\u5f55\u4e2d\u521b\u5efa\u6587\u4ef6\uff0c\u5e76\u67e5\u770b\u65b0\u521b\u5efa\u7684\u6587\u4ef6\u662f\u5426\u4f1a\u7ee7\u627f\u65b0\u521b\u5efa\u7684\u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55\u7684\u6240\u5c5e\u7ec4\u540d\u79f0\uff1a<\/p>\n

[root@linuxprobe tmp]# su - linuxprobe\r\n[linuxprobe@linuxprobe ~]$ cd \/tmp\/testdir\r\n[linuxprobe@linuxprobe testdir]$ echo \"lrxjmw.cn\" > test\r\n[linuxprobe@linuxprobe testdir]$ ls -al test \r\n-rw-rw-r--. 1 linuxprobe root <\/strong>15 Oct 27 23:47 test\r\n<\/pre>\n

\u9664\u4e86\u4e0a\u9762\u63d0\u5230\u7684SGID\u7684\u8fd9\u4e24\u4e2a\u529f\u80fd\uff0c\u518d\u4ecb\u7ecd\u4e24\u4e2a\u4e0e\u672c\u8282\u5185\u5bb9\u76f8\u5173\u7684\u547d\u4ee4\uff1achmod\u548cchown\u3002<\/p>\n

chmod\u547d\u4ee4\u7528\u4e8e\u8bbe\u7f6e\u6587\u4ef6\u7684\u4e00\u822c\u6743\u9650\u53ca\u7279\u6b8a\u6743\u9650\uff0c\u82f1\u6587\u5168\u79f0\u4e3a\u201cchange mode\u201d\uff0c\u8bed\u6cd5\u683c\u5f0f\u4e3a\u201cchmod [\u53c2\u6570]\u00a0\u6587\u4ef6\u540d\u201d\u3002<\/p>\n

\u8fd9\u662f\u4e00\u4e2a\u4e0e\u6587\u4ef6\u6743\u9650\u7684\u65e5\u5e38\u8bbe\u7f6e\u5f3a\u76f8\u5173\u7684\u547d\u4ee4\u3002\u4f8b\u5982\uff0c\u8981\u628a\u4e00\u4e2a\u6587\u4ef6\u7684\u6743\u9650\u8bbe\u7f6e\u6210\u5176\u6240\u6709\u8005\u53ef\u8bfb\u53ef\u5199\u53ef\u6267\u884c\u3001\u6240\u5c5e\u7ec4\u53ef\u8bfb\u53ef\u5199\u3001\u5176\u4ed6\u4eba\u6ca1\u6709\u4efb\u4f55\u6743\u9650\uff0c\u5219\u76f8\u5e94\u7684\u5b57\u7b26\u6cd5\u8868\u793a\u4e3arwxrw----\uff0c\u5176\u5bf9\u5e94\u7684\u6570\u5b57\u6cd5\u8868\u793a\u4e3a760\u3002<\/p>\n

[root@linuxprobe ~]# ls -l anaconda-ks.cfg \r\n-rw-------. 1 root root 1407 Jul 21 05:09 anaconda-ks.cfg\r\n[root@linuxprobe ~]# chmod 760 anaconda-ks.cfg \r\n[root@linuxprobe ~]# ls -l anaconda-ks.cfg \r\n-rwxrw----. 1 root root 1407 Jul 21 05:09 anaconda-ks.cfg\r\n<\/pre>\n

chown\u547d\u4ee4\u7528\u4e8e\u8bbe\u7f6e\u6587\u4ef6\u7684\u6240\u6709\u8005\u548c\u6240\u6709\u7ec4\uff0c\u82f1\u6587\u5168\u79f0\u4e3achange own\uff0c\u8bed\u6cd5\u683c\u5f0f\u4e3a\u201cchown\u6240\u6709\u8005:\u6240\u6709\u7ec4 \u6587\u4ef6\u540d\u201d\u3002<\/p>\n

chmod\u548cchown\u547d\u4ee4\u662f\u7528\u4e8e\u4fee\u6539\u6587\u4ef6\u5c5e\u6027\u548c\u6743\u9650\u7684\u6700\u5e38\u7528\u547d\u4ee4\uff0c\u5b83\u4eec\u8fd8\u6709\u4e00\u4e2a\u7279\u522b\u7684\u5171\u6027\uff0c\u5c31\u662f\u9488\u5bf9\u76ee\u5f55\u8fdb\u884c\u64cd\u4f5c\u65f6\u9700\u8981\u52a0\u4e0a\u5927\u5199\u53c2\u6570-R\u6765\u8868\u793a\u9012\u5f52\u64cd\u4f5c\uff0c\u5373\u5bf9\u76ee\u5f55\u5185\u6240\u6709\u7684\u6587\u4ef6\u8fdb\u884c\u6574\u4f53\u64cd\u4f5c\u3002<\/p>\n

\u4e0b\u9762\u4f7f\u7528\u201c\u6240\u6709\u8005:\u6240\u6709\u7ec4\u201d\u7684\u683c\u5f0f\u628a\u524d\u9762\u90a3\u4e2a\u6587\u4ef6\u7684\u6240\u5c5e\u4fe1\u606f\u8f7b\u677e\u4fee\u6539\u4e00\u4e0b\uff0c\u53d8\u66f4\u540e\u7684\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n

[root@linuxprobe ~]# chown linuxprobe:linuxprobe anaconda-ks.cfg \r\n[root@linuxprobe ~]# ls -l anaconda-ks.cfg \r\n-rwxrw----. 1 linuxprobe linuxprobe<\/strong> 1407 Jul 21 05:09 anaconda-ks.cfg<\/pre>\n

3. \u00a0SBIT<\/strong><\/p>\n

\u73b0\u5728\uff0c\u5927\u5b66\u91cc\u7684\u5f88\u591a\u8001\u5e08\u90fd\u8981\u6c42\u5b66\u751f\u5c06\u4f5c\u4e1a\u4e0a\u4f20\u5230\u670d\u52a1\u5668\u7684\u7279\u5b9a\u5171\u4eab\u76ee\u5f55\u4e2d\uff0c\u4f46\u603b\u662f\u6709\u51e0\u4e2a\u201c\u7834\u574f\u5206\u5b50\u201d\u559c\u6b22\u5220\u9664\u5176\u4ed6\u540c\u5b66\u7684\u4f5c\u4e1a\uff0c\u8fd9\u65f6\u5c31\u8981\u8bbe\u7f6eSBIT\uff08Sticky Bit\uff09\u7279\u6b8a\u6743\u9650\u4f4d\u4e86\uff08\u4e5f\u53ef\u4ee5\u79f0\u4e4b\u4e3a\u7279\u6b8a\u6743\u9650\u4f4d\u4e4b\u7c98\u6ede\u4f4d\uff09\u3002SBIT\u7279\u6b8a\u6743\u9650\u4f4d\u53ef\u786e\u4fdd\u7528\u6237\u53ea\u80fd\u5220\u9664\u81ea\u5df1\u7684\u6587\u4ef6\uff0c\u800c\u4e0d\u80fd\u5220\u9664\u5176\u4ed6\u7528\u6237\u7684\u6587\u4ef6\u3002\u6362\u53e5\u8bdd\u8bf4\uff0c\u5f53\u5bf9\u67d0\u4e2a\u76ee\u5f55\u8bbe\u7f6e\u4e86SBIT\u7c98\u6ede\u4f4d\u6743\u9650\u540e\uff0c\u90a3\u4e48\u8be5\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6\u5c31\u53ea\u80fd\u88ab\u5176\u6240\u6709\u8005\u6267\u884c\u5220\u9664\u64cd\u4f5c\u4e86\u3002<\/p>\n

\u6700\u521d\u4e0d\u77e5\u9053\u662f\u54ea\u4f4d\u975e\u8d44\u6df1\u6280\u672f\u4eba\u5458\u5c06Sticky Bit\u76f4\u8bd1\u6210\u4e86\u201c\u7c98\u6ede\u4f4d\u201d\uff0c\u5218\u9044\u8001\u5e08\u5efa\u8bae\u5c06\u5176\u79f0\u4e3a\u201c\u4fdd\u62a4\u4f4d\u201d\uff0c\u8fd9\u65e2\u597d\u8bb0\uff0c\u53c8\u80fd\u7acb\u523b\u8ba9\u4eba\u4e86\u89e3\u5b83\u7684\u4f5c\u7528\u3002RHEL 8\u7cfb\u7edf\u4e2d\u7684\/tmp\u4f5c\u4e3a\u4e00\u4e2a\u5171\u4eab\u6587\u4ef6\u7684\u76ee\u5f55\uff0c\u9ed8\u8ba4\u5df2\u7ecf\u8bbe\u7f6e\u4e86SBIT\u7279\u6b8a\u6743\u9650\u4f4d\uff0c\u56e0\u6b64\u9664\u975e\u662f\u8be5\u76ee\u5f55\u7684\u6240\u6709\u8005\uff0c\u5426\u5219\u65e0\u6cd5\u5220\u9664\u8fd9\u91cc\u9762\u7684\u6587\u4ef6\u3002<\/p>\n

\u4e0e\u524d\u9762\u6240\u8bb2\u7684SUID\u548cSGID\u6743\u9650\u663e\u793a\u65b9\u6cd5\u4e0d\u540c\uff0c\u5f53\u76ee\u5f55\u88ab\u8bbe\u7f6eSBIT\u7279\u6b8a\u6743\u9650\u4f4d\u540e\uff0c\u6587\u4ef6\u7684\u5176\u4ed6\u7528\u6237\u6743\u9650\u90e8\u5206\u7684x\u6267\u884c\u6743\u9650\u5c31\u4f1a\u88ab\u66ff\u6362\u6210t\u6216\u8005T\u2014\u539f\u672c\u6709x\u6267\u884c\u6743\u9650\u5219\u4f1a\u5199\u6210t\uff0c\u539f\u672c\u6ca1\u6709x\u6267\u884c\u6743\u9650\u5219\u4f1a\u88ab\u5199\u6210T\u3002<\/p>\n

\u7531\u4e0b\u53ef\u77e5\uff0c\/tmp\u76ee\u5f55\u4e0a\u7684SBIT\u6743\u9650\u9ed8\u8ba4\u5df2\u7ecf\u5b58\u5728\uff0c\u8fd9\u4f53\u73b0\u4e3a\u201c\u5176\u4ed6\u7528\u6237\u201d\u6743\u9650\u5b57\u6bb5\u7684\u6743\u9650\u53d8\u4e3arwt\uff1a<\/p>\n

[root@linuxprobe ~]# ls -ald \/tmp\r\ndrwxrwxrwt<\/strong>. 17 root root 4096 Oct 28 00:29 \/tmp\r\n<\/pre>\n

\u5176\u5b9e\uff0c\u6587\u4ef6\u80fd\u5426\u88ab\u5220\u9664\u5e76\u4e0d\u53d6\u51b3\u4e8e\u81ea\u8eab\u7684\u6743\u9650\uff0c\u800c\u662f\u770b\u5176\u6240\u5728\u76ee\u5f55\u662f\u5426\u6709\u5199\u5165\u6743\u9650\uff08\u5176\u539f\u7406\u4f1a\u5728\u4e0b\u4e00\u7ae0\u8bb2\u5230\uff09\u3002\u4e3a\u4e86\u907f\u514d\u73b0\u5728\u5f88\u591a\u8bfb\u8005\u4e0d\u653e\u5fc3\uff0c\u6240\u4ee5\u4e0b\u9762\u7684\u547d\u4ee4\u8fd8\u662f\u8d4b\u4e88\u4e86\u8fd9\u4e2atest\u6587\u4ef6\u6700\u5927\u7684777\u6743\u9650\uff08rwxrwxrwx\uff09\uff1a<\/p>\n

[root@linuxprobe ~]# cd \/tmp\r\n[root@linuxprobe tmp]# echo \"Welcome to lrxjmw.cn\" > test\r\n[root@linuxprobe tmp]# chmod 777 test\r\n[root@linuxprobe tmp]# ls -al test \r\n-rwxrwxrwx. 1 root root 26 Oct 29 14:29 test\r\n<\/pre>\n

\u968f\u540e\uff0c\u5207\u6362\u5230\u4e00\u4e2a\u666e\u901a\u7528\u6237\u8eab\u4efd\u4e0b\uff0c\u5c1d\u8bd5\u5220\u9664\u8fd9\u4e2a\u7531\u5176\u4ed6\u4eba\u521b\u5efa\u7684\u6587\u4ef6\uff0c\u8fd9\u65f6\u5c31\u4f1a\u53d1\u73b0\uff0c\u5373\u4fbf\u8bfb\u3001\u5199\u3001\u6267\u884c\u6743\u9650\u5168\u5f00\uff0c\u4f46\u662f\u7531\u4e8eSBIT\u7279\u6b8a\u6743\u9650\u4f4d\u7684\u7f18\u6545\uff0c\u4f9d\u7136\u65e0\u6cd5\u5220\u9664\u8be5\u6587\u4ef6\uff1a<\/p>\n

[root@linuxprobe tmp]# su - linuxprobe\r\n[linuxprobe@linuxprobe ~]$ cd \/tmp\r\n[linuxprobe@linuxprobe tmp]$ rm -f test\r\nrm: cannot remove 'test': Operation not permitted<\/pre>\n

\u5728\u5de5\u4f5c\u4e2d\uff0c\u82e5\u80fd\u5584\u52a0\u4f7f\u7528\u7279\u6b8a\u6743\u9650\uff0c\u5c31\u80fd\u5b9e\u73b0\u5f88\u591a\u5de7\u5999\u7684\u529f\u80fd\u3002\u4f7f\u7528chmod\u547d\u4ee4\u8bbe\u7f6e\u7279\u6b8a\u6743\u9650\u7684\u53c2\u6570\u5982\u88685-7\u6240\u793a\u3002<\/p>\n

\u88685-7\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 SUID\u3001SGID\u3001SBIT\u7279\u6b8a\u6743\u9650\u7684\u8bbe\u7f6e\u53c2\u6570<\/p>\n\n\n\n\n\n\n\n\n\n
\u53c2\u6570<\/td>\n\u4f5c\u7528<\/td>\n<\/tr>\n
u+s<\/td>\n\u8bbe\u7f6eSUID\u6743\u9650<\/td>\n<\/tr>\n
u-s<\/td>\n\u53d6\u6d88SUID\u6743\u9650<\/td>\n<\/tr>\n
g+s<\/td>\n\u8bbe\u7f6eSGID\u6743\u9650<\/td>\n<\/tr>\n
g-s<\/td>\n\u53d6\u6d88SGID\u6743\u9650<\/td>\n<\/tr>\n
o+t<\/td>\n\u8bbe\u7f6eSBIT\u6743\u9650<\/td>\n<\/tr>\n
o-t<\/td>\n\u53d6\u6d88SBIT\u6743\u9650<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

<\/p>\n

\u5207\u6362\u56deroot\u7ba1\u7406\u5458\u7684\u8eab\u4efd\u4e0b\uff0c\u5728\u5bb6\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3alinux\u7684\u65b0\u76ee\u5f55\uff0c\u968f\u540e\u4e3a\u5176\u8bbe\u7f6eSBIT\u6743\u9650\uff1a<\/p>\n

[linuxprobe@linuxprobe tmp]$ exit\r\nLogout\r\n[root@linuxprobe tmp]# cd ~\r\n[root@linuxprobe ~]# mkdir linux\r\n[root@linuxprobe ~]# chmod -R o+t linux\/\r\n[root@linuxprobe ~]# ls -ld linux\/\r\ndrwxr-xr-t. 2 root root 6 Feb 11 19:34 linux\/<\/pre>\n

\u4e0a\u8ff0\u4ee3\u7801\u4e2d\u7684o+t\u53c2\u6570\u662f\u5728\u4e00\u822c\u6743\u9650\u5df2\u7ecf\u8bbe\u7f6e\u5b8c\u6bd5\u7684\u524d\u63d0\u4e0b\uff0c\u53c8\u65b0\u589e\u4e86\u4e00\u9879\u7279\u6b8a\u6743\u9650\u3002\u5982\u679c\u6211\u4eec\u60f3\u5c06\u4e00\u822c\u6743\u9650\u548c\u7279\u6b8a\u6743\u9650\u4e00\u8d77\u8bbe\u7f6e\uff0c\u6709\u4ec0\u4e48\u9ad8\u6548\u7387\u7684\u65b9\u6cd5\u4e48\uff1f<\/p>\n

\u5176\u5b9e\uff0cSUID\u3001SGID\u4e0eSBIT\u4e5f\u6709\u5bf9\u5e94\u7684\u6570\u5b57\u8868\u793a\u6cd5\uff0c\u5206\u522b\u4e3a4\u30012\u30011\u3002\u4e5f\u5c31\u662f\u8bf4777\u8fd8\u4e0d\u662f\u6700\u5927\u6743\u9650\uff0c\u6700\u5927\u6743\u9650\u5e94\u8be5\u662f7777\uff0c\u5176\u4e2d\u7b2c1\u4e2a\u6570\u5b57\u4ee3\u8868\u7684\u662f\u7279\u6b8a\u6743\u9650\u4f4d\u3002\u65e2\u7136\u77e5\u9053\u4e86\u6570\u5b57\u8868\u793a\u6cd5\u662f\u7531\u201c\u7279\u6b8a\u6743\u9650+\u4e00\u822c\u6743\u9650\u201d\u6784\u6210\u7684\uff0c\u73b0\u5728\u5c31\u4ee5\u4e0a\u9762linux\u76ee\u5f55\u7684\u6743\u9650\u4e3a\u4f8b\uff0c\u4e3a\u5927\u5bb6\u68b3\u7406\u4e00\u4e0b\u8ba1\u7b97\u65b9\u6cd5\u3002<\/p>\n

\u5728rwxr-xr-t\u6743\u9650\u4e2d\uff0c\u6700\u540e\u4e00\u4f4d\u662ft\uff0c\u8fd9\u8bf4\u660e\u8be5\u6587\u4ef6\u7684\u4e00\u822c\u6743\u9650\u4e3arwxr-xr-x\uff0c\u5e76\u5e26\u6709SBIT\u7279\u6b8a\u6743\u9650\u3002\u5bf9\u4e8e\u53ef\u8bfb\uff08r\uff09\u3001\u53ef\u5199\uff08w\uff09\u3001\u53ef\u6267\u884c\uff08x\uff09\u6743\u9650\u7684\u6570\u5b57\u8ba1\u7b97\u65b9\u6cd5\u5927\u5bb6\u5e94\u8be5\u5f88\u719f\u6089\u4e86\u2014rwxr-xr-x\u5373755\uff0c\u800cSBIT\u7279\u6b8a\u6743\u9650\u4f4d\u662f1\uff0c\u5219\u5408\u5e76\u540e\u7684\u7ed3\u679c\u4e3a1755\u3002<\/p>\n

\u518d\u589e\u52a0\u70b9\u96be\u5ea6\uff0c\u5982\u679c\u6743\u9650\u662f\u201crwsrwSr--\u201d\u5462\uff1f\u9996\u5148\u4e0d\u8981\u614c\uff0c\u5927\u5199S\u8868\u793a\u539f\u5148\u6ca1\u6709\u6267\u884c\u6743\u9650\uff0c\u56e0\u6b64\u4e00\u822c\u6743\u9650\u4e3arwxrw-r--\uff0c\u5c06\u5176\u8f6c\u6362\u4e3a\u6570\u5b57\u8868\u793a\u6cd5\u540e\u7ed3\u679c\u662f764\u3002\u5e26\u6709\u7684SUID\u548cSGID\u7279\u6b8a\u6743\u9650\u7684\u6570\u5b57\u6cd5\u8868\u793a\u662f4\u548c2\uff0c\u5fc3\u7b97\u5f97\u51fa\u7ed3\u679c\u662f6\uff0c\u5408\u5e76\u540e\u7684\u7ed3\u679c\u4e3a6764\u3002\u8fd9\u4e2a\u793a\u4f8b\u786e\u5b9e\u96be\u5ea6\u5927\u4e00\u4e9b\uff0c\u5927\u5bb6\u53ef\u4ee5\u5b66\u4e60\u53c2\u8003\u56fe5-4\u7684\u8ba1\u7b97\u8fc7\u7a0b\uff0c\u5728\u641e\u660e\u767d\u540e\u518d\u5f80\u4e0b\u770b\u3002<\/p>\n

\u5c06\u6743\u9650\u7684\u6570\u5b57\u8868\u793a\u6cd5\u8f6c\u6362\u6210\u5b57\u7b26\u8868\u793a\u6cd5\u7684\u96be\u5ea6\u7565\u5fae\u9ad8\u4e00\u4e9b\uff0c\u8fd9\u91cc\u4ee55537\u4e3a\u4f8b\u8bb2\u89e3\u3002\u9996\u5148\uff0c\u7279\u6b8a\u6743\u9650\u76845\u662f\u75314+1\u7ec4\u6210\u7684\uff0c\u610f\u5473\u7740\u6709SUID\u548cSBIT\u3002SUID\u548cSGID\u7684\u5199\u6cd5\u662f\uff0c\u539f\u5148\u6709\u6267\u884c\u6743\u9650\u5219\u662f\u5c0f\u5199s\uff0c\u5982\u679c\u6ca1\u6709\u6267\u884c\u6743\u9650\u5219\u662f\u5927\u5199S\uff1b\u800cSBIT\u7684\u5199\u6cd5\u5219\u662f\uff0c\u539f\u5148\u6709\u6267\u884c\u6743\u9650\u662f\u5c0f\u5199t\uff0c\u6ca1\u6709\u6267\u884c\u6743\u9650\u662f\u5927\u5199T\u3002\u4e00\u822c\u6743\u9650\u7684537\u8fdb\u884c\u5b57\u7b26\u8f6c\u6362\u540e\u5e94\u4e3ar-x-wxrwx\uff0c\u7136\u540e\u5728\u6b64\u57fa\u7840\u4e0a\u589e\u52a0SUID\u548cSBIT\u7279\u6b8a\u6743\u9650\uff0c\u5408\u5e76\u540e\u7684\u7ed3\u679c\u662fr-s-wxrwt\u3002\u5927\u5bb6\u53ef\u4ee5\u53c2\u8003\u56fe5-5\u6240\u793a\u7684\u8ba1\u7b97\u8fc7\u7a0b\u6765\u5e2e\u52a9\u7406\u89e3\u3002<\/p>\n

\"\"<\/p>\n

\u56fe5-4 \u6743\u9650\u7684\u5b57\u7b26\u8868\u793a\u6cd5\u8f6c\u6570\u5b57\u8868\u793a\u6cd5<\/p>\n

\"\"<\/p>\n

\u56fe5-5 \u6743\u9650\u7684\u6570\u5b57\u8868\u793a\u6cd5\u8f6c\u5b57\u7b26\u6807\u8bc6\u6cd5<\/p>\n

\n
\n

Tips<\/h3>\n<\/div>\n
\n

\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u6587\u4ef6\u7684\u6743\u9650\u4f4d\u6709\u70b9\u50cf\u5317\u4eac\u7684\u623f\u4ef7\uff0c\u5bf8\u571f\u5bf8\u91d1\uff0c\u4e00\u4e2a\u6743\u9650\u4f4d\u7adf\u80fd\u6709\u8fd9\u4e48\u591a\u542b\u4e49\uff0c\u5927\u5bb6\u5de5\u4f5c\u4e2d\u4e00\u5b9a\u8981\u5c0f\u5fc3\u8c28\u614e\u3002<\/p>\n<\/div>\n<\/div>\n

\u51fa\u73b0\u95ee\u9898?\u5927\u80c6\u63d0\u95ee!<\/strong><\/span><\/p>\n

\u56e0\u8bfb\u8005\u4eec\u786c\u4ef6\u4e0d\u540c\u6216\u64cd\u4f5c\u9519\u8bef\u90fd\u53ef\u80fd\u5bfc\u81f4\u5b9e\u9a8c\u914d\u7f6e\u51fa\u9519\uff0c\u8bf7\u8010\u5fc3\u518d\u4ed4\u7ec6\u770b\u770b\u64cd\u4f5c\u6b65\u9aa4\u5427\uff0c\u4e0d\u8981\u6c14\u9981~<\/p>\n

Linux\u6280\u672f\u4ea4\u6d41\u5b66\u4e60\u8bf7\u52a0\u8bfb\u8005\u7fa4\uff08\u63a8\u8350<\/span><\/strong>\uff09\uff1ahttps:\/\/lrxjmw.cn\/club<\/a><\/p>\n

*\u672c\u7fa4\u7279\u8272\uff1a\u786e\u4fdd\u6bcf\u4e00\u4f4d\u7fa4\u53cb\u90fd\u662f\u300aLinux\u5c31\u8be5\u8fd9\u4e48\u5b66\u300b\u7684\u8bfb\u8005\uff0c\u7b54\u7591\u66f4\u6709\u9488\u5bf9\u6027\uff0c\u4e0d\u5b9a\u671f\u9886\u53d6\u5b9a\u5236\u793c\u54c1\u3002<\/p><\/blockquote>\n

5.4 \u6587\u4ef6\u7684\u9690\u85cf\u5c5e\u6027<\/strong><\/span><\/h5>\n

Linux\u7cfb\u7edf\u4e2d\u7684\u6587\u4ef6\u9664\u4e86\u5177\u5907\u4e00\u822c\u6743\u9650\u548c\u7279\u6b8a\u6743\u9650\u4e4b\u5916\uff0c\u8fd8\u6709\u4e00\u79cd\u9690\u85cf\u6743\u9650\uff0c\u5373\u88ab\u9690\u85cf\u8d77\u6765\u7684\u6743\u9650\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4e0d\u80fd\u76f4\u63a5\u88ab\u7528\u6237\u53d1\u89c9\u3002\u6709\u7528\u6237\u66fe\u7ecf\u5728\u751f\u4ea7\u73af\u5883\u548cRHCE\u8003\u8bd5\u9898\u76ee\u4e2d\u78b0\u5230\u8fc7\u660e\u660e\u6743\u9650\u5145\u8db3\u4f46\u5374\u65e0\u6cd5\u5220\u9664\u67d0\u4e2a\u6587\u4ef6\u7684\u60c5\u51b5\uff0c\u6216\u8005\u4ec5\u80fd\u5728\u65e5\u5fd7\u6587\u4ef6\u4e2d\u8ffd\u52a0\u5185\u5bb9\u800c\u4e0d\u80fd\u4fee\u6539\u6216\u5220\u9664\u5185\u5bb9\u7684\u60c5\u51b5\uff0c\u8fd9\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u963b\u6b62\u4e86\u9ed1\u5ba2\u7be1\u6539\u7cfb\u7edf\u65e5\u5fd7\u7684\u56fe\u8c0b\uff0c\u56e0\u6b64\u8fd9\u79cd\u201c\u5947\u602a\u201d\u7684\u6587\u4ef6\u6743\u9650\u4e5f\u4fdd\u969c\u4e86Linux\u7cfb\u7edf\u7684\u5b89\u5168\u6027\u3002<\/p>\n

\u65e2\u7136\u53eb\u9690\u85cf\u6743\u9650\uff0c\u90a3\u4e48\u4f7f\u7528\u5e38\u89c4\u7684ls\u547d\u4ee4\u80af\u5b9a\u4e0d\u80fd\u770b\u5230\u5b83\u7684\u771f\u9762\u76ee\u3002\u9690\u85cf\u6743\u9650\u7684\u4e13\u7528\u8bbe\u7f6e\u547d\u4ee4\u662fchattr\uff0c\u4e13\u7528\u67e5\u770b\u547d\u4ee4\u662flsattr\u3002<\/p>\n

1. \u00a0chattr\u547d\u4ee4<\/strong><\/p>\n

chattr\u547d\u4ee4\u7528\u4e8e\u8bbe\u7f6e\u6587\u4ef6\u7684\u9690\u85cf\u6743\u9650\uff0c\u82f1\u6587\u5168\u79f0\u4e3achange attributes\uff0c\u8bed\u6cd5\u683c\u5f0f\u4e3a\u201cchattr [\u53c2\u6570]\u00a0\u6587\u4ef6\u540d\u79f0\u201d\u3002<\/p>\n

\u5982\u679c\u60f3\u8981\u628a\u67d0\u4e2a\u9690\u85cf\u529f\u80fd\u6dfb\u52a0\u5230\u6587\u4ef6\u4e0a\uff0c\u5219\u9700\u8981\u5728\u547d\u4ee4\u540e\u9762\u8ffd\u52a0\u201c+\u53c2\u6570\u201d\uff0c\u5982\u679c\u60f3\u8981\u628a\u67d0\u4e2a\u9690\u85cf\u529f\u80fd\u79fb\u51fa\u6587\u4ef6\uff0c\u5219\u9700\u8981\u8ffd\u52a0\u201c-\u53c2\u6570\u201d\u3002chattr\u547d\u4ee4\u4e2d\u53ef\u4f9b\u9009\u62e9\u7684\u9690\u85cf\u6743\u9650\u53c2\u6570\u975e\u5e38\u4e30\u5bcc\uff0c\u5177\u4f53\u5982\u88685-8\u6240\u793a\u3002<\/p>\n

\u88685-8\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 chattr\u547d\u4ee4\u4e2d\u7684\u53c2\u6570\u53ca\u5176\u4f5c\u7528<\/p>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u53c2\u6570<\/td>\n\u4f5c\u7528<\/td>\n<\/tr>\n
i<\/td>\n\u65e0\u6cd5\u5bf9\u6587\u4ef6\u8fdb\u884c\u4fee\u6539\uff1b\u82e5\u5bf9\u76ee\u5f55\u8bbe\u7f6e\u4e86\u8be5\u53c2\u6570\uff0c\u5219\u4ec5\u80fd\u4fee\u6539\u5176\u4e2d\u7684\u5b50\u6587\u4ef6\u5185\u5bb9\u800c\u4e0d\u80fd\u65b0\u5efa\u6216\u5220\u9664\u6587\u4ef6<\/td>\n<\/tr>\n
a<\/td>\n\u4ec5\u5141\u8bb8\u8865\u5145\uff08\u8ffd\u52a0\uff09\u5185\u5bb9\uff0c\u65e0\u6cd5\u8986\u76d6\/\u5220\u9664\u5185\u5bb9\uff08Append Only\uff09<\/td>\n<\/tr>\n
S<\/td>\n\u6587\u4ef6\u5185\u5bb9\u5728\u53d8\u66f4\u540e\u7acb\u5373\u540c\u6b65\u5230\u786c\u76d8\uff08sync\uff09<\/td>\n<\/tr>\n
s<\/td>\n\u5f7b\u5e95\u4ece\u786c\u76d8\u4e2d\u5220\u9664\uff0c\u4e0d\u53ef\u6062\u590d\uff08\u75280\u586b\u5145\u539f\u6587\u4ef6\u6240\u5728\u786c\u76d8\u533a\u57df\uff09<\/td>\n<\/tr>\n
A<\/td>\n\u4e0d\u518d\u4fee\u6539\u8fd9\u4e2a\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u6700\u540e\u8bbf\u95ee\u65f6\u95f4\uff08atime\uff09<\/td>\n<\/tr>\n
b<\/td>\n\u4e0d\u518d\u4fee\u6539\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u5b58\u53d6\u65f6\u95f4<\/td>\n<\/tr>\n
D<\/td>\n\u68c0\u67e5\u538b\u7f29\u6587\u4ef6\u4e2d\u7684\u9519\u8bef<\/td>\n<\/tr>\n
d<\/td>\n\u4f7f\u7528dump\u547d\u4ee4\u5907\u4efd\u65f6\u5ffd\u7565\u672c\u6587\u4ef6\/\u76ee\u5f55<\/td>\n<\/tr>\n
c<\/td>\n\u9ed8\u8ba4\u5c06\u6587\u4ef6\u6216\u76ee\u5f55\u8fdb\u884c\u538b\u7f29<\/td>\n<\/tr>\n
u<\/td>\n\u5f53\u5220\u9664\u8be5\u6587\u4ef6\u540e\u4f9d\u7136\u4fdd\u7559\u5176\u5728\u786c\u76d8\u4e2d\u7684\u6570\u636e\uff0c\u65b9\u4fbf\u65e5\u540e\u6062\u590d<\/td>\n<\/tr>\n
t<\/td>\n\u8ba9\u6587\u4ef6\u7cfb\u7edf\u652f\u6301\u5c3e\u90e8\u5408\u5e76\uff08tail-merging\uff09<\/td>\n<\/tr>\n
x<\/td>\n\u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee\u538b\u7f29\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

<\/p>\n

\u4e3a\u4e86\u8ba9\u8bfb\u8005\u80fd\u591f\u66f4\u597d\u5730\u89c1\u8bc6\u9690\u85cf\u6743\u9650\u7684\u6548\u679c\uff0c\u6211\u4eec\u5148\u6765\u521b\u5efa\u4e00\u4e2a\u666e\u901a\u6587\u4ef6\uff0c\u7136\u540e\u7acb\u5373\u5c1d\u8bd5\u5220\u9664\uff08\u8fd9\u4e2a\u64cd\u4f5c\u80af\u5b9a\u4f1a\u6210\u529f\uff09\uff1a<\/p>\n

[root@linuxprobe ~]# echo \"for Test\" > linuxprobe\r\n[root@linuxprobe ~]# rm linuxprobe\r\nrm: remove regular file \u2018linuxprobe\u2019? y\r\n<\/pre>\n

\u5b9e\u8df5\u662f\u68c0\u9a8c\u771f\u7406\u7684\u552f\u4e00\u6807\u51c6\u3002\u5982\u679c\u60a8\u6ca1\u6709\u4eb2\u773c\u89c1\u8bc1\u8fc7\u9690\u85cf\u6743\u9650\u5f3a\u5927\u529f\u80fd\u7684\u7f8e\u5999\uff0c\u5c31\u4e00\u5b9a\u4e0d\u4f1a\u76f8\u4fe1\u539f\u6765Linux\u7cfb\u7edf\u4f1a\u5982\u6b64\u5b89\u5168\u3002\u63a5\u4e0b\u6765\u518d\u6b21\u65b0\u5efa\u4e00\u4e2a\u666e\u901a\u6587\u4ef6\uff0c\u5e76\u4e3a\u5176\u8bbe\u7f6e\u201c\u4e0d\u5141\u8bb8\u5220\u9664\u4e0e\u8986\u76d6\u201d\uff08+a\u53c2\u6570\uff09\u6743\u9650\uff0c\u7136\u540e\u518d\u5c1d\u8bd5\u5c06\u8fd9\u4e2a\u6587\u4ef6\u5220\u9664\uff1a<\/p>\n

[root@linuxprobe ~]# echo \"for Test\" > linuxprobe\r\n[root@linuxprobe ~]# chattr +a linuxprobe\r\n[root@linuxprobe ~]# rm linuxprobe\r\nrm: remove regular file \u2018linuxprobe\u2019? y\r\nrm: cannot remove \u2018linuxprobe\u2019: Operation not permitted<\/pre>\n

\u53ef\u89c1\uff0c\u4e0a\u8ff0\u64cd\u4f5c\u5931\u8d25\u4e86\u3002<\/p>\n

2. \u00a0lsattr\u547d\u4ee4<\/strong><\/p>\n

lsattr\u547d\u4ee4\u7528\u4e8e\u67e5\u770b\u6587\u4ef6\u7684\u9690\u85cf\u6743\u9650\uff0c\u82f1\u6587\u5168\u79f0\u4e3a\u201clist attributes\u201d\uff0c\u8bed\u6cd5\u683c\u5f0f\u4e3a\u201clsattr [\u53c2\u6570]\u00a0\u6587\u4ef6\u540d\u79f0\u201d\u3002<\/p>\n

\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u6587\u4ef6\u7684\u9690\u85cf\u6743\u9650\u5fc5\u987b\u4f7f\u7528lsattr\u547d\u4ee4\u6765\u67e5\u770b\uff0c\u5e73\u65f6\u4f7f\u7528\u7684ls\u4e4b\u7c7b\u7684\u547d\u4ee4\u5219\u770b\u4e0d\u51fa\u7aef\u502a\uff1a<\/p>\n

[root@linuxprobe ~]# ls -al linuxprobe\r\n-rw-r--r--. 1 root root 9 Feb 12 11:42 linuxprobe<\/pre>\n

\u4e00\u65e6\u4f7f\u7528lsattr\u547d\u4ee4\u540e\uff0c\u6587\u4ef6\u4e0a\u88ab\u8d4b\u4e88\u7684\u9690\u85cf\u6743\u9650\u9a6c\u4e0a\u5c31\u4f1a\u539f\u5f62\u6bd5\u9732\uff1a<\/p>\n

[root@linuxprobe ~]# lsattr linuxprobe\r\n-----a<\/strong>---------- linuxprobe<\/pre>\n

\u6b64\u65f6\u6309\u7167\u663e\u793a\u7684\u9690\u85cf\u6743\u9650\u7684\u7c7b\u578b\uff08\u5b57\u6bcd\uff09\uff0c\u4f7f\u7528chattr\u547d\u4ee4\u5c06\u5176\u53bb\u6389\uff1a<\/p>\n

[root@linuxprobe ~]# chattr -a linuxprobe\r\n[root@linuxprobe ~]# lsattr linuxprobe \r\n---------------- linuxprobe\r\n[root@linuxprobe ~]# rm linuxprobe \r\nrm: remove regular file \u2018linuxprobe\u2019? y\r\n<\/pre>\n

\u6211\u4eec\u4e00\u822c\u4f1a\u5c06-a\u53c2\u6570\u8bbe\u7f6e\u5230\u65e5\u5fd7\u6587\u4ef6\uff08\/var\/log\/messages\uff09\u4e0a\uff0c\u8fd9\u6837\u53ef\u5728\u4e0d\u5f71\u54cd\u7cfb\u7edf\u6b63\u5e38\u5199\u5165\u65e5\u5fd7\u7684\u524d\u63d0\u4e0b\uff0c\u9632\u6b62\u9ed1\u5ba2\u64e6\u9664\u81ea\u5df1\u7684\u4f5c\u6848\u8bc1\u636e\u3002\u5982\u679c\u5e0c\u671b\u5f7b\u5e95\u5730\u4fdd\u62a4\u67d0\u4e2a\u6587\u4ef6\uff0c\u4e0d\u5141\u8bb8\u4efb\u4f55\u4eba\u4fee\u6539\u548c\u5220\u9664\u5b83\u7684\u8bdd\uff0c\u4e0d\u59a8\u52a0\u4e0a-i\u53c2\u6570\u8bd5\u8bd5\uff0c\u6548\u679c\u7279\u522b\u597d\u3002<\/p>\n

\u5728\u7f8e\u5267\u300a\u8d8a\u72f1\u300b\u7684\u7b2c\u4e00\u5b63\u4e2d\uff0c\u4e3b\u4eba\u516c\u8fc8\u514b\u5c14\u00b7\u65af\u79d1\u83f2\u5c14\u5fb7\u628a\u88c5\u6709\u8d8a\u72f1\u8ba1\u5212\u7684\u786c\u76d8\u5f00\u7a97\u6254\u8fdb\u4e86\u6e56\u4e2d\uff0c\u7ed3\u679c\u5728\u7b2c\u4e8c\u5b63\u88ab\u8b66\u63a2\u6253\u635e\u51fa\u6765\u6062\u590d\u4e86\u6570\u636e\uff0c\u7136\u540e\u5c31\u6709\u4e86\u7b2c\u4e8c\u5b63\u3001\u7b2c\u4e09\u5b63\u3001\u7b2c\u56db\u5b63\u3001\u7b2c\u4e94\u5b63\uff0c\u4ed6\u548c\u54e5\u54e5\u7684\u9003\u4ea1\u6545\u4e8b\u3002\u6240\u4ee5\uff0c\u8981\u60f3\u5f7b\u5e95\u5220\u9664\u67d0\u4e2a\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528+s\u53c2\u6570\u6765\u4fdd\u8bc1\u5176\u88ab\u5220\u9664\u540e\u4e0d\u53ef\u6062\u590d\u2014\u786c\u76d8\u4e0a\u7684\u6587\u4ef6\u6570\u636e\u4f1a\u88ab\u7528\u96f6\u5757\u91cd\u65b0\u586b\u5145\uff0c\u90a3\u5c31\u66f4\u4fdd\u9669\u4e86\u3002<\/p>\n

5.5\u00a0\u6587\u4ef6\u8bbf\u95ee\u63a7\u5236\u5217\u8868<\/strong><\/span><\/h5>\n

\u4e0d\u77e5\u9053\u5927\u5bb6\u662f\u5426\u53d1\u73b0\uff0c\u524d\u6587\u8bb2\u89e3\u7684\u4e00\u822c\u6743\u9650\u3001\u7279\u6b8a\u6743\u9650\u3001\u9690\u85cf\u6743\u9650\u5176\u5b9e\u6709\u4e00\u4e2a\u5171\u6027\u2014\u6743\u9650\u662f\u9488\u5bf9\u67d0\u4e00\u7c7b\u7528\u6237\u8bbe\u7f6e\u7684\uff0c\u80fd\u591f\u5bf9\u5f88\u591a\u4eba\u540c\u65f6\u751f\u6548\u3002\u5982\u679c\u5e0c\u671b\u5bf9\u67d0\u4e2a\u6307\u5b9a\u7684\u7528\u6237\u8fdb\u884c\u5355\u72ec\u7684\u6743\u9650\u63a7\u5236\uff0c\u5c31\u9700\u8981\u7528\u5230\u6587\u4ef6\u7684\u8bbf\u95ee\u63a7\u5236\u5217\u8868\uff08ACL\uff09\u4e86\u3002\u901a\u4fd7\u6765\u8bb2\uff0c\u57fa\u4e8e\u666e\u901a\u6587\u4ef6\u6216\u76ee\u5f55\u8bbe\u7f6eACL\u5176\u5b9e\u5c31\u662f\u9488\u5bf9\u6307\u5b9a\u7684\u7528\u6237\u6216\u7528\u6237\u7ec4\u8bbe\u7f6e\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u64cd\u4f5c\u6743\u9650\uff0c\u66f4\u52a0\u7cbe\u51c6\u5730\u6d3e\u53d1\u6743\u9650\u3002\u53e6\u5916\uff0c\u5982\u679c\u9488\u5bf9\u67d0\u4e2a\u76ee\u5f55\u8bbe\u7f6e\u4e86ACL\uff0c\u5219\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6\u4f1a\u7ee7\u627f\u5176ACL\u6743\u9650\uff1b\u82e5\u9488\u5bf9\u6587\u4ef6\u8bbe\u7f6e\u4e86ACL\uff0c\u5219\u6587\u4ef6\u4e0d\u518d\u7ee7\u627f\u5176\u6240\u5728\u76ee\u5f55\u7684ACL\u6743\u9650\u3002<\/p>\n

\u4e3a\u4e86\u66f4\u76f4\u89c2\u5730\u770b\u5230ACL\u5bf9\u6587\u4ef6\u6743\u9650\u63a7\u5236\u7684\u5f3a\u5927\u6548\u679c\uff0c\u6211\u4eec\u5148\u5207\u6362\u5230\u666e\u901a\u7528\u6237\uff0c\u7136\u540e\u5c1d\u8bd5\u8fdb\u5165root\u7ba1\u7406\u5458\u7684\u5bb6\u76ee\u5f55\u4e2d\u3002\u5728\u6ca1\u6709\u9488\u5bf9\u666e\u901a\u7528\u6237\u4e3aroot\u7ba1\u7406\u5458\u7684\u5bb6\u76ee\u5f55\u8bbe\u7f6eACL\u4e4b\u524d\uff0c\u5176\u6267\u884c\u7ed3\u679c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n

[root@linuxprobe ~]# su - linuxprobe\r\n[linuxprobe@linuxprobe ~]$ cd \/root\r\n-bash: cd: \/root: Permission denied<\/strong>\r\n[linuxprobe@linuxprobe root]$ exit<\/pre>\n

1. \u00a0setfacl\u547d\u4ee4<\/strong><\/p>\n

setfacl\u547d\u4ee4\u7528\u4e8e\u7ba1\u7406\u6587\u4ef6\u7684ACL\u6743\u9650\u89c4\u5219\uff0c\u82f1\u6587\u5168\u79f0\u4e3a\u201cset files ACL\u201d\uff0c\u8bed\u6cd5\u683c\u5f0f\u4e3a\u201csetfacl [\u53c2\u6570]\u00a0\u6587\u4ef6\u540d\u79f0\u201d\u3002<\/p>\n

ACL\u6743\u9650\u63d0\u4f9b\u7684\u662f\u5728\u6240\u6709\u8005\u3001\u6240\u5c5e\u7ec4\u3001\u5176\u4ed6\u4eba\u7684\u8bfb\/\u5199\/\u6267\u884c\u6743\u9650\u4e4b\u5916\u7684\u7279\u6b8a\u6743\u9650\u63a7\u5236\u3002\u4f7f\u7528setfacl\u547d\u4ee4\u53ef\u4ee5\u9488\u5bf9\u5355\u4e00\u7528\u6237\u6216\u7528\u6237\u7ec4\u3001\u5355\u4e00\u6587\u4ef6\u6216\u76ee\u5f55\u6765\u8fdb\u884c\u8bfb\/\u5199\/\u6267\u884c\u6743\u9650\u7684\u63a7\u5236\u3002\u5176\u4e2d\uff0c\u9488\u5bf9\u76ee\u5f55\u6587\u4ef6\u9700\u8981\u4f7f\u7528-R\u9012\u5f52\u53c2\u6570\uff1b\u9488\u5bf9\u666e\u901a\u6587\u4ef6\u5219\u4f7f\u7528-m\u53c2\u6570\uff1b\u5982\u679c\u60f3\u8981\u5220\u9664\u67d0\u4e2a\u6587\u4ef6\u7684ACL\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528-b\u53c2\u6570\u3002setfacl\u547d\u4ee4\u7684\u5e38\u7528\u53c2\u6570\u5982\u88685-9\u6240\u793a\u3002<\/p>\n

\u88685-9\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 setfacl\u547d\u4ee4\u4e2d\u7684\u53c2\u6570\u4ee5\u53ca\u4f5c\u7528<\/p>\n\n\n\n\n\n\n\n\n
\u53c2\u6570<\/td>\n\u4f5c\u7528<\/td>\n<\/tr>\n
-m<\/td>\n\u4fee\u6539\u6743\u9650<\/td>\n<\/tr>\n
-M<\/td>\n\u4ece\u6587\u4ef6\u4e2d\u8bfb\u53d6\u6743\u9650<\/td>\n<\/tr>\n
-x<\/td>\n\u5220\u9664\u67d0\u4e2a\u6743\u9650<\/td>\n<\/tr>\n
-b<\/td>\n\u5220\u9664\u5168\u90e8\u6743\u9650<\/td>\n<\/tr>\n
-R<\/td>\n\u9012\u5f52\u5b50\u76ee\u5f55<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

<\/p>\n

\u4f8b\u5982\uff0c\u6211\u4eec\u539f\u672c\u662f\u65e0\u6cd5\u8fdb\u5165\/root\u76ee\u5f55\u4e2d\u7684\uff0c\u73b0\u5728\u4e3a\u666e\u901a\u7528\u6237\u5355\u72ec\u8bbe\u7f6e\u4e00\u4e0b\u6743\u9650\uff1a<\/p>\n

[root@linuxprobe ~]# setfacl -Rm u:linuxprobe:rwx \/root\r\n<\/pre>\n

\u968f\u540e\u518d\u5207\u6362\u5230\u8fd9\u4f4d\u666e\u901a\u7528\u6237\u7684\u8eab\u4efd\u4e0b\uff0c\u73b0\u5728\u80fd\u6b63\u5e38\u8fdb\u5165\u4e86\uff1a<\/p>\n

[root@linuxprobe ~]# su - linuxprobe\r\n[linuxprobe@linuxprobe ~]$ cd \/root\r\n[linuxprobe@linuxprobe root]$ ls\r\nanaconda-ks.cfg  Documents  initial-setup-ks.cfg  Pictures  Templates\r\nDesktop          Downloads  Music                 Public    Videos\r\n[linuxprobe@linuxprobe root]$ exit<\/pre>\n

\u662f\u4e0d\u662f\u89c9\u5f97\u6548\u679c\u5f88\u9177\u5462\uff1f\u4f46\u662f\u73b0\u5728\u6709\u8fd9\u6837\u4e00\u4e2a\u5c0f\u95ee\u9898\u2014\u600e\u4e48\u53bb\u67e5\u770b\u6587\u4ef6\u662f\u5426\u8bbe\u7f6e\u4e86ACL\u5462\uff1f\u5e38\u7528\u7684ls\u547d\u4ee4\u662f\u770b\u4e0d\u5230ACL\u4fe1\u606f\u7684\uff0c\u4f46\u662f\u5374\u53ef\u4ee5\u770b\u5230\u6587\u4ef6\u6743\u9650\u7684\u6700\u540e\u4e00\u4e2a\u70b9\uff08.<\/strong>\uff09\u53d8\u6210\u4e86\u52a0\u53f7\uff08+<\/strong>\uff09\uff0c\u8fd9\u5c31\u610f\u5473\u7740\u8be5\u6587\u4ef6\u5df2\u7ecf\u8bbe\u7f6e\u4e86ACL\u3002\u73b0\u5728\u5927\u5bb6\u662f\u4e0d\u662f\u611f\u89c9\u5b66\u5f97\u8d8a\u591a\uff0c\u8d8a\u4e0d\u6562\u8bf4\u81ea\u5df1\u7cbe\u901aLinux\u7cfb\u7edf\u4e86\u5427\uff1f\u5c31\u8fd9\u4e48\u4e00\u4e2a\u4e0d\u8d77\u773c\u7684\u70b9\uff08.\uff09\uff0c\u7adf\u7136\u8fd8\u8868\u793a\u8fd9\u4e48\u4e00\u79cd\u91cd\u8981\u7684\u6743\u9650\u3002<\/p>\n

[root@linuxprobe ~]# ls -ld \/root\r\ndr-xrwx---+<\/strong> 14 root root 4096 May 4 2020 \/root<\/pre>\n

2. \u00a0getfacl\u547d\u4ee4<\/strong><\/p>\n

getfacl\u547d\u4ee4\u7528\u4e8e\u67e5\u770b\u6587\u4ef6\u7684ACL\u6743\u9650\u89c4\u5219\uff0c\u82f1\u6587\u5168\u79f0\u4e3a\u201cget files ACL\u201d\uff0c\u8bed\u6cd5\u683c\u5f0f\u4e3a\u201cgetfacl [\u53c2\u6570]\u00a0\u6587\u4ef6\u540d\u79f0\u201d\u3002<\/p>\n

Linux\u7cfb\u7edf\u4e2d\u7684\u547d\u4ee4\u5c31\u662f\u8fd9\u4e48\u53c8\u53ef\u7231\u53c8\u597d\u8bb0\u3002\u60f3\u8981\u8bbe\u7f6eACL\uff0c\u7528\u7684\u662fsetfacl\u547d\u4ee4\uff1b\u8981\u60f3\u67e5\u770bACL\uff0c\u5219\u7528\u7684\u662fgetfacl\u547d\u4ee4\u3002\u4e0b\u9762\u4f7f\u7528getfacl\u547d\u4ee4\u663e\u793a\u5728root\u7ba1\u7406\u5458\u5bb6\u76ee\u5f55\u4e0a\u8bbe\u7f6e\u7684\u6240\u6709ACL\u4fe1\u606f\uff1a<\/p>\n

[root@linuxprobe ~]# getfacl \/root\r\nggetfacl: Removing leading '\/' from absolute path names\r\n# file: root\r\n# owner: root\r\n# group: root\r\nuser::r-x\r\nuser:linuxprobe:rwx<\/strong>\r\ngroup::r-x\r\nmask::rwx\r\nother::---\r\n<\/pre>\n

ACL\u6743\u9650\u8fd8\u53ef\u4ee5\u9488\u5bf9\u67d0\u4e2a\u7528\u6237\u7ec4\u8fdb\u884c\u8bbe\u7f6e\u3002\u4f8b\u5982\uff0c\u5141\u8bb8\u67d0\u4e2a\u7ec4\u7684\u7528\u6237\u90fd\u53ef\u4ee5\u8bfb\u5199\/etc\/fstab\u6587\u4ef6\uff1a<\/p>\n

[root@linuxprobe ~]# setfacl -m g:linuxprobe:rw \/etc\/fstab\r\n[root@linuxprobe ~]# getfacl \/etc\/fstab \r\ngetfacl: Removing leading '\/' from absolute path names\r\n# file: etc\/fstab\r\n# owner: root\r\n# group: root\r\nuser::rw-\r\ngroup::r--\r\ngroup:linuxprobe:rw-<\/strong>\r\nmask::rw-\r\nother::r--<\/pre>\n

\u8bbe\u7f6e\u9519\u4e86\u60f3\u5220\u9664\uff1f\u6ca1\u95ee\u9898\uff01\u8981\u6e05\u7a7a\u6240\u6709ACL\u6743\u9650\uff0c\u8bf7\u7528-b\u53c2\u6570\uff1b\u8981\u5220\u9664\u67d0\u4e00\u6761\u6307\u5b9a\u7684\u6743\u9650\uff0c\u5c31\u7528-x\u53c2\u6570\uff1a<\/p>\n

[root@linuxprobe ~]# setfacl -x g:linuxprobe \/etc\/fstab\r\n[root@linuxprobe ~]# getfacl \/etc\/fstab \r\ngetfacl: Removing leading '\/' from absolute path names\r\n# file: etc\/fstab\r\n# owner: root\r\n# group: root\r\nuser::rw-\r\ngroup::r--\r\nmask::r--\r\nother::r--<\/pre>\n

ACL\u6743\u9650\u7684\u8bbe\u7f6e\u90fd\u662f\u7acb\u5373\u4e14\u6c38\u4e45\u751f\u6548\u7684\uff0c\u4e0d\u9700\u8981\u518d\u7f16\u8f91\u4ec0\u4e48\u914d\u7f6e\u6587\u4ef6\uff0c\u8fd9\u4e00\u70b9\u7279\u522b\u65b9\u4fbf\u3002\u4f46\u662f\uff0c\u8fd9\u4e5f\u5e26\u6765\u4e86\u4e00\u4e2a\u5b89\u5168\u9690\u60a3\u3002\u5982\u679c\u6211\u4eec\u4e0d\u5c0f\u5fc3\u8bbe\u7f6e\u9519\u4e86\u6743\u9650\uff0c\u5c31\u4f1a\u8986\u76d6\u6389\u6587\u4ef6\u539f\u59cb\u7684\u6743\u9650\u4fe1\u606f\uff0c\u5e76\u4e14\u6c38\u8fdc\u90fd\u627e\u4e0d\u56de\u6765\u4e86\u3002<\/p>\n

\u64cd\u4f5c\u524d\u5907\u4efd\u4e00\u4e0b\uff0c\u603b\u662f\u597d\u7684\u4e60\u60ef<\/strong><\/p>\n

\u4f8b\u5982\uff0c\u5728\u5907\u4efd\/home\u76ee\u5f55\u4e0a\u7684ACL\u6743\u9650\u65f6\uff0c\u53ef\u4f7f\u7528-R\u9012\u5f52\u53c2\u6570\uff0c\u8fd9\u6837\u4e0d\u4ec5\u80fd\u591f\u628a\u76ee\u5f55\u672c\u8eab\u7684\u6743\u9650\u8fdb\u884c\u5907\u4efd\uff0c\u8fd8\u80fd\u5c06\u91cc\u9762\u7684\u6587\u4ef6\u6743\u9650\u4e5f\u81ea\u52a8\u5907\u4efd\u3002\u53e6\u5916\uff0c\u518d\u52a0\u4e0a\u7b2c3\u7ae0\u5b66\u4e60\u8fc7\u7684\u8f93\u51fa\u91cd\u5b9a\u5411\u64cd\u4f5c\uff0c\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u6743\u9650\u7684\u5907\u4efd\u3002\u9700\u8981\u6ce8\u610f\uff0cgetfacl\u5728\u5907\u4efd\u76ee\u5f55\u6743\u9650\u65f6\u4e0d\u80fd\u4f7f\u7528\u7edd\u5bf9\u8def\u5f84\u7684\u5f62\u5f0f\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u5148\u5207\u6362\u5230\u6700\u4e0a\u5c42\u6839\u76ee\u5f55\uff0c\u7136\u540e\u518d\u8fdb\u884c\u64cd\u4f5c\u3002<\/p>\n

[root@linuxprobe ~]# cd \/\r\n[root@linuxprobe \/]# getfacl -R home > backup.acl\r\n[root@linuxprobe \/]# ls -l \r\n-rw-r--r--. 1 root root 834 Jul 18 14:14 backup.acl\r\n<\/pre>\n

ACL\u6743\u9650\u7684\u6062\u590d\u4e5f\u5f88\u7b80\u5355\uff0c\u4f7f\u7528\u7684\u662f--restore\u53c2\u6570\u3002\u7531\u4e8e\u5728\u5907\u4efd\u65f6\u5df2\u7ecf\u6307\u5b9a\u662f\u5bf9\/home\u76ee\u5f55\u8fdb\u884c\u64cd\u4f5c\uff0c\u6240\u4ee5\u4e0d\u9700\u8981\u5199\u5bf9\u5e94\u7684\u76ee\u5f55\u540d\u79f0\uff0c\u5b83\u80fd\u591f\u81ea\u52a8\u627e\u5230\u8981\u6062\u590d\u7684\u5bf9\u8c61\uff1a<\/p>\n

[root@linuxprobe \/]# setfacl --restore backup.acl<\/pre>\n
5.6 su\u547d\u4ee4\u4e0esudo\u670d\u52a1<\/strong><\/span><\/h5>\n

\u5404\u4f4d\u8bfb\u8005\u5728\u5b9e\u9a8c\u73af\u5883\u4e2d\u5f88\u5c11\u9047\u5230\u5b89\u5168\u95ee\u9898\uff0c\u5e76\u4e14\u4e3a\u4e86\u907f\u514d\u56e0\u6743\u9650\u56e0\u7d20\u5bfc\u81f4\u914d\u7f6e\u670d\u52a1\u5931\u8d25\uff0c\u4ece\u800c\u5efa\u8bae\u4f7f\u7528root\u7ba1\u7406\u5458\u7684\u8eab\u4efd\u6765\u5b66\u4e60\u672c\u4e66\u3002\u4f46\u662f\uff0c\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u8fd8\u662f\u8981\u5bf9\u5b89\u5168\u591a\u4e00\u4efd\u656c\u754f\u4e4b\u5fc3\uff0c\u4e0d\u8981\u7528root\u7ba1\u7406\u5458\u7684\u8eab\u4efd\u53bb\u505a\u6240\u6709\u4e8b\u60c5\u3002\u56e0\u4e3a\u4e00\u65e6\u6267\u884c\u4e86\u9519\u8bef\u7684\u547d\u4ee4\uff0c\u53ef\u80fd\u4f1a\u76f4\u63a5\u5bfc\u81f4\u7cfb\u7edf\u5d29\u6e83\u3002\u8fd9\u6837\u4e00\u6765\uff0c\u4e0d\u4f46\u5ba2\u6237\u6307\u8d23\u3001\u9886\u5bfc\u6279\u8bc4\uff0c\u6ca1\u51c6\u5956\u91d1\u4e5f\u4f1a\u9e21\u98de\u86cb\u6253\u3002\u4f46\u8f6c\u5934\u4e00\u60f3\uff0c\u5c3d\u7ba1Linux\u7cfb\u7edf\u4e3a\u4e86\u5b89\u5168\u6027\u8003\u8651\uff0c\u4f7f\u5f97\u8bb8\u591a\u7cfb\u7edf\u547d\u4ee4\u548c\u670d\u52a1\u53ea\u80fd\u88abroot\u7ba1\u7406\u5458\u6765\u4f7f\u7528\uff0c\u4f46\u662f\u8fd9\u4e5f\u8ba9\u666e\u901a\u7528\u6237\u53d7\u5230\u4e86\u66f4\u591a\u7684\u6743\u9650\u675f\u7f1a\uff0c\u4ece\u800c\u5bfc\u81f4\u65e0\u6cd5\u987a\u5229\u5b8c\u6210\u7279\u5b9a\u7684\u5de5\u4f5c\u4efb\u52a1\u3002<\/p>\n

su\u547d\u4ee4\u53ef\u4ee5\u89e3\u51b3\u5207\u6362\u7528\u6237\u8eab\u4efd\u7684\u9700\u6c42\uff0c\u4f7f\u5f97\u5f53\u524d\u7528\u6237\u5728\u4e0d\u9000\u51fa\u767b\u5f55\u7684\u60c5\u51b5\u4e0b\uff0c\u987a\u7545\u5730\u5207\u6362\u5230\u5176\u4ed6\u7528\u6237\uff0c\u6bd4\u5982\u4eceroot\u7ba1\u7406\u5458\u5207\u6362\u81f3\u666e\u901a\u7528\u6237\uff1a<\/p>\n

[root@linuxprobe ~]# su - linuxprobe\r\n[linuxprobe@linuxprobe ~]$ id\r\nuid=1000(linuxprobe) gid=1000(linuxprobe) groups=1000(linuxprobe) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023\r\n<\/pre>\n

\u7ec6\u5fc3\u7684\u8bfb\u8005\u4e00\u5b9a\u4f1a\u53d1\u73b0\uff0c\u4e0a\u9762\u7684su\u547d\u4ee4\u4e0e\u7528\u6237\u540d\u4e4b\u95f4\u6709\u4e00\u4e2a\u51cf\u53f7\uff08-\uff09\uff0c\u8fd9\u610f\u5473\u7740\u5b8c\u5168\u5207\u6362\u5230\u65b0\u7684\u7528\u6237\uff0c\u5373\u628a\u73af\u5883\u53d8\u91cf\u4fe1\u606f\u4e5f\u53d8\u66f4\u4e3a\u65b0\u7528\u6237\u7684\u76f8\u5e94\u4fe1\u606f\uff0c\u800c\u4e0d\u662f\u4fdd\u7559\u539f\u59cb\u7684\u4fe1\u606f\u3002\u5f3a\u70c8\u5efa\u8bae\u5728\u5207\u6362\u7528\u6237\u8eab\u4efd\u65f6\u6dfb\u52a0\u8fd9\u4e2a\u51cf\u53f7\uff08-\uff09\u3002<\/p>\n

\u53e6\u5916\uff0c\u5f53\u4eceroot\u7ba1\u7406\u5458\u5207\u6362\u5230\u666e\u901a\u7528\u6237\u65f6\u662f\u4e0d\u9700\u8981\u5bc6\u7801\u9a8c\u8bc1\u7684\uff0c\u800c\u4ece\u666e\u901a\u7528\u6237\u5207\u6362\u6210root\u7ba1\u7406\u5458\u5c31\u9700\u8981\u8fdb\u884c\u5bc6\u7801\u9a8c\u8bc1\u4e86\uff1b\u8fd9\u4e5f\u662f\u4e00\u4e2a\u5fc5\u8981\u7684\u5b89\u5168\u68c0\u67e5\uff1a<\/p>\n

[linuxprobe@linuxprobe ~]$ su - root\r\nPassword: \u6b64\u5904\u8f93\u5165\u7ba1\u7406\u5458\u5bc6\u7801<\/strong>\r\n[root@linuxprobe ~]# \r\n<\/pre>\n

\u5c3d\u7ba1\u50cf\u4e0a\u9762\u8fd9\u6837\u4f7f\u7528su\u547d\u4ee4\u540e\uff0c\u666e\u901a\u7528\u6237\u53ef\u4ee5\u5b8c\u5168\u5207\u6362\u5230root\u7ba1\u7406\u5458\u7684\u8eab\u4efd\u6765\u5b8c\u6210\u76f8\u5e94\u5de5\u4f5c\uff0c\u4f46\u8fd9\u5c06\u66b4\u9732root\u7ba1\u7406\u5458\u7684\u5bc6\u7801\uff0c\u4ece\u800c\u589e\u5927\u4e86\u7cfb\u7edf\u5bc6\u7801\u88ab\u9ed1\u5ba2\u83b7\u53d6\u7684\u6982\u7387\uff1b\u8fd9\u5e76\u4e0d\u662f\u6700\u5b89\u5168\u7684\u65b9\u6848\u3002<\/p>\n

\u5218\u9044\u8001\u5e08\u63a5\u4e0b\u6765\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528sudo\u547d\u4ee4\u628a\u7279\u5b9a\u547d\u4ee4\u7684\u6267\u884c\u6743\u9650\u8d4b\u4e88\u6307\u5b9a\u7528\u6237\uff0c\u8fd9\u6837\u65e2\u53ef\u4fdd\u8bc1\u666e\u901a\u7528\u6237\u80fd\u591f\u5b8c\u6210\u7279\u5b9a\u7684\u5de5\u4f5c\uff0c\u4e5f\u53ef\u4ee5\u907f\u514d\u6cc4\u9732root\u7ba1\u7406\u5458\u5bc6\u7801\u3002\u6211\u4eec\u8981\u505a\u7684\u5c31\u662f\u5408\u7406\u914d\u7f6esudo\u670d\u52a1\uff0c\u4ee5\u4fbf\u517c\u987e\u7cfb\u7edf\u7684\u5b89\u5168\u6027\u548c\u7528\u6237\u7684\u4fbf\u6377\u6027\u3002<\/p>\n

\n
\n

Tips<\/strong><\/h3>\n<\/div>\n
\n

\u6388\u6743\u539f\u5219\uff1a<\/strong>\u5728\u4fdd\u8bc1\u666e\u901a\u7528\u6237\u5b8c\u6210\u76f8\u5e94\u5de5\u4f5c\u7684\u524d\u63d0\u4e0b\uff0c\u5c3d\u53ef\u80fd\u5c11\u5730\u8d4b\u4e88\u989d\u5916\u7684\u6743\u9650\u3002<\/p>\n<\/div>\n<\/div>\n

sudo\u547d\u4ee4\u7528\u4e8e\u7ed9\u666e\u901a\u7528\u6237\u63d0\u4f9b\u989d\u5916\u7684\u6743\u9650\uff0c\u8bed\u6cd5\u683c\u5f0f\u4e3a\u201csudo [\u53c2\u6570]\u00a0\u7528\u6237\u540d\u201d\u3002<\/p>\n

\u4f7f\u7528sudo\u547d\u4ee4\u53ef\u4ee5\u7ed9\u666e\u901a\u7528\u6237\u63d0\u4f9b\u989d\u5916\u7684\u6743\u9650\u6765\u5b8c\u6210\u539f\u672c\u53ea\u6709root\u7ba1\u7406\u5458\u624d\u80fd\u5b8c\u6210\u7684\u4efb\u52a1\uff0c\u53ef\u4ee5\u9650\u5236\u7528\u6237\u6267\u884c\u6307\u5b9a\u7684\u547d\u4ee4\uff0c\u8bb0\u5f55\u7528\u6237\u6267\u884c\u8fc7\u7684\u6bcf\u4e00\u6761\u547d\u4ee4\uff0c\u96c6\u4e2d\u7ba1\u7406\u7528\u6237\u4e0e\u6743\u9650\uff08\/etc\/sudoers\uff09\uff0c\u4ee5\u53ca\u53ef\u4ee5\u5728\u9a8c\u8bc1\u5bc6\u7801\u540e\u7684\u4e00\u6bb5\u65f6\u95f4\u65e0\u987b\u8ba9\u7528\u6237\u518d\u6b21\u9a8c\u8bc1\u5bc6\u7801\u3002\u5e38\u89c1\u7684sudo\u547d\u4ee4\u7684\u53ef\u7528\u53c2\u6570\u5982\u88685-10\u6240\u793a\u3002<\/p>\n

\u88685-10\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 sudo\u547d\u4ee4\u4e2d\u7684\u53ef\u7528\u53c2\u6570\u4ee5\u53ca\u4f5c\u7528<\/p>\n\n\n\n\n\n\n\n\n\n
\u53c2\u6570<\/td>\n\u4f5c\u7528<\/td>\n<\/tr>\n
-h<\/td>\n\u5217\u51fa\u5e2e\u52a9\u4fe1\u606f<\/td>\n<\/tr>\n
-l<\/td>\n\u5217\u51fa\u5f53\u524d\u7528\u6237\u53ef\u6267\u884c\u7684\u547d\u4ee4<\/td>\n<\/tr>\n
-u \u7528\u6237\u540d\u6216UID\u503c<\/td>\n\u4ee5\u6307\u5b9a\u7684\u7528\u6237\u8eab\u4efd\u6267\u884c\u547d\u4ee4<\/td>\n<\/tr>\n
-k<\/td>\n\u6e05\u7a7a\u5bc6\u7801\u7684\u6709\u6548\u65f6\u95f4\uff0c\u4e0b\u6b21\u6267\u884csudo\u65f6\u9700\u8981\u518d\u6b21\u8fdb\u884c\u5bc6\u7801\u9a8c\u8bc1<\/td>\n<\/tr>\n
-b<\/td>\n\u5728\u540e\u53f0\u6267\u884c\u6307\u5b9a\u7684\u547d\u4ee4<\/td>\n<\/tr>\n
-p<\/td>\n\u66f4\u6539\u8be2\u95ee\u5bc6\u7801\u7684\u63d0\u793a\u8bed<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

<\/p>\n

\u5f53\u7136\uff0c\u5982\u679c\u62c5\u5fc3\u76f4\u63a5\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u4f1a\u51fa\u73b0\u95ee\u9898\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528sudo\u547d\u4ee4\u63d0\u4f9b\u7684visudo\u547d\u4ee4\u6765\u914d\u7f6e\u7528\u6237\u6743\u9650\u3002<\/p>\n

visudo\u547d\u4ee4\u7528\u4e8e\u7f16\u8f91\u3001\u914d\u7f6e\u7528\u6237sudo\u7684\u6743\u9650\u6587\u4ef6\uff0c\u8bed\u6cd5\u683c\u5f0f\u4e3a\u201cvisudo [\u53c2\u6570]\u201d\u3002<\/p>\n

\u8fd9\u662f\u4e00\u6761\u4f1a\u81ea\u52a8\u8c03\u7528vi\u7f16\u8f91\u5668\u6765\u914d\u7f6e\/etc\/sudoers\u6743\u9650\u6587\u4ef6\u7684\u547d\u4ee4\uff0c\u80fd\u591f\u89e3\u51b3\u591a\u4e2a\u7528\u6237\u540c\u65f6\u4fee\u6539\u6743\u9650\u800c\u5bfc\u81f4\u7684\u51b2\u7a81\u95ee\u9898\u3002\u4e0d\u4ec5\u5982\u6b64\uff0cvisudo\u547d\u4ee4\u8fd8\u53ef\u4ee5\u5bf9\u914d\u7f6e\u6587\u4ef6\u5185\u7684\u53c2\u6570\u8fdb\u884c\u8bed\u6cd5\u68c0\u67e5\uff0c\u5e76\u5728\u53d1\u73b0\u53c2\u6570\u9519\u8bef\u65f6\u8fdb\u884c\u62a5\u9519\u63d0\u9192\u3002\u8fd9\u8981\u6bd4\u7528\u6237\u76f4\u63a5\u4fee\u6539\u6587\u4ef6\u66f4\u53cb\u597d\u3001\u5b89\u5168\u3001\u65b9\u4fbf\u3002<\/p>\n

>>> \/etc\/sudoers: syntax error near line 1 <<<<\/strong>\r\nWhat now? \r\nOptions are:\r\n(e)dit sudoers file again\r\ne(x)it without saving changes to sudoers file\r\n(Q)uit and save changes to sudoers file (DANGER!)<\/pre>\n

\u4f7f\u7528visudo\u547d\u4ee4\u914d\u7f6e\u6743\u9650\u6587\u4ef6\u65f6\uff0c\u5176\u64cd\u4f5c\u65b9\u6cd5\u4e0eVim\u7f16\u8f91\u5668\u4e2d\u7528\u5230\u7684\u65b9\u6cd5\u5b8c\u5168\u4e00\u81f4\uff0c\u56e0\u6b64\u5728\u7f16\u5199\u5b8c\u6210\u540e\u8bb0\u5f97\u5728\u672b\u884c\u6a21\u5f0f\u4e0b\u4fdd\u5b58\u5e76\u9000\u51fa\u3002\u5728\u914d\u7f6e\u6743\u9650\u6587\u4ef6\u65f6\uff0c\u6309\u7167\u4e0b\u9762\u7684\u683c\u5f0f\u5728\u7b2c101\u884c\uff08\u5927\u7ea6\uff09\u586b\u5199\u4e0a\u6307\u5b9a\u7684\u4fe1\u606f\u3002<\/p>\n

\u8c01\u53ef\u4ee5\u4f7f\u7528 \u5141\u8bb8\u4f7f\u7528\u7684\u4e3b\u673a = \uff08\u4ee5\u8c01\u7684\u8eab\u4efd\uff09 \u53ef\u6267\u884c\u547d\u4ee4\u7684\u5217\u8868<\/strong><\/span><\/p>\n

\u8c01\u53ef\u4ee5\u4f7f\u7528\uff1a<\/strong>\u7a0d\u540e\u8981\u4e3a\u54ea\u4f4d\u7528\u6237\u8fdb\u884c\u547d\u4ee4\u6388\u6743\u3002<\/p>\n

\u5141\u8bb8\u4f7f\u7528\u7684\u4e3b\u673a\uff1a<\/strong>\u53ef\u4ee5\u586b\u5199ALL\u8868\u793a\u4e0d\u9650\u5236\u6765\u6e90\u7684\u4e3b\u673a\uff0c\u4ea6\u53ef\u586b\u5199\u5982192.168.10.0\/24\u8fd9\u6837\u7684\u7f51\u6bb5\u9650\u5236\u6765\u6e90\u5730\u5740\uff0c\u4f7f\u5f97\u53ea\u6709\u4ece\u5141\u8bb8\u7f51\u6bb5\u767b\u5f55\u65f6\u624d\u80fd\u4f7f\u7528sudo\u547d\u4ee4\u3002<\/p>\n

\u4ee5\u8c01\u7684\u8eab\u4efd\uff1a<\/strong>\u53ef\u4ee5\u586b\u5199ALL\u8868\u793a\u7cfb\u7edf\u6700\u9ad8\u6743\u9650\uff0c\u4e5f\u53ef\u4ee5\u662f\u53e6\u5916\u4e00\u4f4d\u7528\u6237\u7684\u540d\u5b57\u3002<\/p>\n

\u53ef\u6267\u884c\u547d\u4ee4\u7684\u5217\u8868\uff1a<\/strong>\u53ef\u4ee5\u586b\u5199ALL\u8868\u793a\u4e0d\u9650\u5236\u547d\u4ee4\uff0c\u4ea6\u53ef\u586b\u5199\u5982\/usr\/bin\/cat\u8fd9\u6837\u7684\u6587\u4ef6\u540d\u79f0\u6765\u9650\u5236\u547d\u4ee4\u5217\u8868\uff0c\u591a\u4e2a\u547d\u4ee4\u6587\u4ef6\u4e4b\u95f4\u7528\u9017\u53f7\uff08,\uff09\u95f4\u9694\u3002<\/p><\/blockquote>\n

\u5728Linux\u7cfb\u7edf\u4e2d\u914d\u7f6e\u670d\u52a1\u6587\u4ef6\u65f6\uff0c\u867d\u7136\u6ca1\u6709\u786c\u6027\u89c4\u5b9a\uff0c\u4f46\u4ece\u7ecf\u9a8c\u6765\u8bb2\u65b0\u589e\u53c2\u6570\u7684\u4f4d\u7f6e\u4e0d\u5efa\u8bae\u592a\u9760\u4e0a\uff0c\u4ee5\u514d\u6211\u4eec\u65b0\u586b\u5199\u7684\u53c2\u6570\u5728\u6267\u884c\u65f6\u5931\u8d25\uff0c\u5bfc\u81f4\u4e00\u4e9b\u5fc5\u8981\u7684\u670d\u52a1\u529f\u80fd\u6ca1\u6709\u6210\u529f\u52a0\u8f7d\u3002\u4e00\u822c\u5efa\u8bae\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u627e\u4e00\u4e0b\u76f8\u4f3c\u7684\u53c2\u6570\uff0c\u7136\u540e\u5728\u76f8\u90bb\u4f4d\u7f6e\u8fdb\u884c\u65b0\u7684\u4fee\u6539\uff0c\u6216\u8005\u5728\u6587\u4ef6\u7684\u4e2d\u4e0b\u90e8\u4f4d\u7f6e\u8fdb\u884c\u6dfb\u52a0\u540e\u4fee\u6539\u3002<\/p>\n

[root@linuxprobe ~]# visudo\r\n 99 ## Allow root to run any commands anywhere\r\n100 root ALL=(ALL) ALL\r\n101 linuxprobe ALL=(ALL) ALL\r\n<\/strong><\/pre>\n

\u5728\u586b\u5199\u5b8c\u6bd5\u540e\u8bb0\u5f97\u8981\u5148\u4fdd\u5b58\u518d\u9000\u51fa\uff0c\u7136\u540e\u5207\u6362\u81f3\u6307\u5b9a\u7684\u666e\u901a\u7528\u6237\u8eab\u4efd\uff0c\u6b64\u65f6\u5c31\u53ef\u4ee5\u7528sudo -l\u547d\u4ee4\u67e5\u770b\u6240\u6709\u53ef\u6267\u884c\u7684\u547d\u4ee4\u4e86\uff08\u5728\u4e0b\u9762\u7684\u547d\u4ee4\u4e2d\uff0c\u9a8c\u8bc1\u7684\u662f\u666e\u901a\u7528\u6237\u7684\u5bc6\u7801\uff0c\u800c\u4e0d\u662froot\u7ba1\u7406\u5458\u7684\u5bc6\u7801\uff0c\u8bf7\u8bfb\u8005\u4e0d\u8981\u641e\u6df7\u4e86\uff09\uff1a<\/p>\n

[root@linuxprobe ~]# su - linuxprobe\r\n[linuxprobe@linuxprobe ~]$ sudo -l\r\nWe trust you have received the usual lecture from the local System\r\nAdministrator. It usually boils down to these three things:\r\n\r\n    #1) Respect the privacy of others.\r\n    #2) Think before you type.\r\n    #3) With great power comes great responsibility.\r\n\r\n[sudo] password for linuxprobe: \u6b64\u5904\u8f93\u5165linuxprobe\u7528\u6237\u7684\u5bc6\u7801<\/strong>\r\nMatching Defaults entries for linuxprobe on localhost:\r\n    !visiblepw, always_set_home, match_group_by_gid, always_query_group_plugin,\r\n    env_reset, env_keep=\"COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS\",\r\n    env_keep+=\"MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE\",\r\n    env_keep+=\"LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES\",\r\n    env_keep+=\"LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE\",\r\n    env_keep+=\"LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY\",\r\n    secure_path=\/sbin\\:\/bin\\:\/usr\/sbin\\:\/usr\/bin\r\n\r\nUser linuxprobe may run the following commands on localhost:\r\n    (ALL) ALL\r\n<\/strong><\/pre>\n

\u63a5\u4e0b\u6765\u662f\u89c1\u8bc1\u5947\u8ff9\u7684\u65f6\u523b\uff01\u4f5c\u4e3a\u4e00\u540d\u666e\u901a\u7528\u6237\uff0c\u662f\u80af\u5b9a\u4e0d\u80fd\u770b\u5230root\u7ba1\u7406\u5458\u7684\u5bb6\u76ee\u5f55\uff08\/root\uff09\u4e2d\u7684\u6587\u4ef6\u4fe1\u606f\u7684\uff0c\u4f46\u662f\uff0c\u53ea\u9700\u8981\u5728\u60f3\u6267\u884c\u7684\u547d\u4ee4\u524d\u9762\u52a0\u4e0asudo\u547d\u4ee4\u5c31\u884c\u4e86\uff1a<\/p>\n

[linuxprobe@linuxprobe ~]$ ls \/root\r\nls: cannot open directory '\/root': Permission denied\r\n[linuxprobe@linuxprobe ~]$ sudo ls \/root\r\nanaconda-ks.cfg  Documents  initial-setup-ks.cfg  Pictures  Templates\r\nDesktop\t\t Downloads  Music\t\t  Public    Videos\r\n<\/pre>\n

\u6548\u679c\u7acb\u7aff\u89c1\u5f71\uff01\u4f46\u662f\u8003\u8651\u5230\u751f\u4ea7\u73af\u5883\u4e2d\u4e0d\u5141\u8bb8\u67d0\u4e2a\u666e\u901a\u7528\u6237\u62e5\u6709\u6574\u4e2a\u7cfb\u7edf\u4e2d\u6240\u6709\u547d\u4ee4\u7684\u6700\u9ad8\u6267\u884c\u6743\uff08\u8fd9\u4e5f\u4e0d\u7b26\u5408\u524d\u6587\u63d0\u5230\u7684\u6743\u9650\u8d4b\u4e88\u539f\u5219\uff0c\u5373\u5c3d\u53ef\u80fd\u5c11\u5730\u8d4b\u4e88\u6743\u9650\uff09\uff0cALL\u53c2\u6570\u5c31\u6709\u4e9b\u4e0d\u5408\u9002\u4e86\u3002\u56e0\u6b64\u53ea\u80fd\u8d4b\u4e88\u666e\u901a\u7528\u6237\u5177\u4f53\u7684\u547d\u4ee4\u4ee5\u6ee1\u8db3\u5de5\u4f5c\u9700\u6c42\uff0c\u8fd9\u4e5f\u53d7\u5230\u4e86\u5fc5\u8981\u7684\u6743\u9650\u7ea6\u675f\u3002\u5982\u679c\u9700\u8981\u8ba9\u67d0\u4e2a\u7528\u6237\u53ea\u80fd\u4f7f\u7528root\u7ba1\u7406\u5458\u7684\u8eab\u4efd\u6267\u884c\u6307\u5b9a\u7684\u547d\u4ee4\uff0c\u5207\u8bb0\u4e00\u5b9a\u8981\u7ed9\u51fa\u8be5\u547d\u4ee4\u7684\u7edd\u5bf9\u8def\u5f84\uff0c\u5426\u5219\u7cfb\u7edf\u4f1a\u8bc6\u522b\u4e0d\u51fa\u6765\u3002\u8fd9\u65f6\uff0c\u53ef\u4ee5\u5148\u4f7f\u7528whereis\u547d\u4ee4\u627e\u51fa\u547d\u4ee4\u6240\u5bf9\u5e94\u7684\u4fdd\u5b58\u8def\u5f84\uff1a<\/p>\n

[linuxprobe@linuxprobe ~]$ exit \r\nlogout \r\n[root@linuxprobe ~]# whereis cat \r\ncat: \/usr\/bin\/cat<\/strong> \/usr\/share\/man\/man1\/cat.1.gz \/usr\/share\/man\/man1p\/cat.1p.gz\r\n[root@linuxprobe ~]# whereis reboot\r\nreboot: \/usr\/sbin\/reboot<\/strong> \/usr\/share\/man\/man2\/reboot.2.gz \/usr\/share\/man\/man8\/reboot.8.gz<\/pre>\n

\u7136\u540e\u4f7f\u7528visudo\u547d\u4ee4\u7ee7\u7eed\u7f16\u8f91\u6743\u9650\u6587\u4ef6\uff0c\u5c06\u539f\u5148\u7b2c101\u884c\u6240\u65b0\u589e\u7684\u53c2\u6570\u4f5c\u5982\u4e0b\u4fee\u6539\uff0c\u4e14\u591a\u4e2a\u547d\u4ee4\u4e4b\u95f4\u7528\u9017\u53f7\uff08,\uff09\u95f4\u9694\uff1a<\/p>\n

[root@linuxprobe ~]# visudo\r\n 99 ## Allow root to run any commands anywhere\r\n100 root ALL=(ALL) ALL\r\n101 linuxprobe ALL=(ALL) \/usr\/bin\/cat,\/usr\/sbin\/reboot<\/strong><\/pre>\n

\u5728\u7f16\u8f91\u597d\u540e\u4f9d\u7136\u662f\u5148\u4fdd\u5b58\u518d\u9000\u51fa\u3002\u518d\u6b21\u5207\u6362\u5230\u6307\u5b9a\u7684\u666e\u901a\u7528\u6237\uff0c\u7136\u540e\u5c1d\u8bd5\u6b63\u5e38\u67e5\u770b\u67d0\u4e2a\u7cfb\u7edf\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u6b64\u65f6\u7cfb\u7edf\u63d0\u793a\u6ca1\u6709\u6743\u9650\uff08Permission denied\uff09\u3002\u8fd9\u65f6\u518d\u4f7f\u7528sudo\u547d\u4ee4\u5c31\u80fd\u987a\u5229\u5730\u67e5\u770b\u6587\u4ef6\u5185\u5bb9\u4e86\uff1a<\/p>\n

[root@linuxprobe ~]# su - linuxprobe\r\n[linuxprobe@linuxprobe ~]$ cat \/etc\/shadow\r\ncat: \/etc\/shadow: Permission denied\r\n[linuxprobe@linuxprobe ~]$ sudo cat \/etc\/shadow\r\n[sudo] password for linuxprobe: \u6b64\u5904\u8f93\u5165linuxprobe\u7528\u6237\u7684\u5bc6\u7801<\/strong>\r\nroot:$6$tTbuw5DkOPYqq.vI$RMk9FCGHoJOq2qAPRURTQm.Qok2nN3yFn\/i4f\/falVGgGND9XoiYFbrxDn16WWiziaSJ0\/cR06U66ipEoGLPJ.::0:99999:7:::\r\nbin:*:17784:0:99999:7:::\r\ndaemon:*:17784:0:99999:7:::\r\nadm:*:17784:0:99999:7:::\r\nlp:*:17784:0:99999:7:::\r\nsync:*:17784:0:99999:7:::\r\nshutdown:*:17784:0:99999:7:::\r\nhalt:*:17784:0:99999:7:::\r\n\u2026\u2026\u2026\u2026\u2026\u2026\u7701\u7565\u90e8\u5206\u8f93\u51fa\u4fe1\u606f\u2026\u2026\u2026\u2026\u2026\u2026\r\n[linuxprobe@linuxprobe ~]$ exit \r\nlogout<\/pre>\n

\u5927\u5bb6\u5343\u4e07\u4e0d\u8981\u4ee5\u4e3a\u5230\u8fd9\u91cc\u5c31\u7ed3\u675f\u4e86\uff0c\u5218\u9044\u8001\u5e08\u8fd8\u6709\u66f4\u538b\u7bb1\u5e95\u7684\u5b9d\u8d1d\u3002\u4e0d\u77e5\u5927\u5bb6\u662f\u5426\u53d1\u89c9\u5728\u6bcf\u6b21\u6267\u884csudo\u547d\u4ee4\u540e\u90fd\u4f1a\u8981\u6c42\u9a8c\u8bc1\u4e00\u4e0b\u5bc6\u7801\u3002\u867d\u7136\u8fd9\u4e2a\u5bc6\u7801\u5c31\u662f\u5f53\u524d\u767b\u5f55\u7528\u6237\u7684\u5bc6\u7801\uff0c\u4f46\u662f\u6bcf\u6b21\u6267\u884csudo\u547d\u4ee4\u90fd\u8981\u8f93\u5165\u4e00\u6b21\u5bc6\u7801\u5176\u5b9e\u4e5f\u633a\u9ebb\u70e6\u7684\uff0c\u8fd9\u65f6\u53ef\u4ee5\u6dfb\u52a0NOPASSWD\u53c2\u6570\uff0c\u4f7f\u5f97\u7528\u6237\u4e0b\u6b21\u518d\u6267\u884csudo\u547d\u4ee4\u65f6\u5c31\u4e0d\u7528\u5bc6\u7801\u9a8c\u8bc1\uff1a<\/p>\n

[root@linuxprobe ~]# visudo\r\n 99 ## Allow root to run any commands anywhere\r\n100 root ALL=(ALL) ALL\r\n101 linuxprobe ALL=(ALL) NOPASSWD:<\/strong>\/usr\/bin\/cat,\/usr\/sbin\/reboot<\/pre>\n

\u8fd9\u6837\uff0c\u5f53\u5207\u6362\u5230\u666e\u901a\u7528\u6237\u540e\u518d\u6267\u884c\u547d\u4ee4\u65f6\uff0c\u5c31\u4e0d\u7528\u518d\u9891\u7e41\u5730\u9a8c\u8bc1\u5bc6\u7801\u4e86\uff0c\u6211\u4eec\u5728\u65e5\u5e38\u5de5\u4f5c\u4e2d\u4e5f\u5c31\u75db\u5feb\u81f3\u6781\u4e86\u3002<\/p>\n

[root@linuxprobe ~]# su - linuxprobe\r\n[linuxprobe@linuxprobe ~]$ reboot\r\nUser root is logged in on tty2.\r\nPlease retry operation after closing inhibitors and logging out other users.\r\nAlternatively, ignore inhibitors and users with 'systemctl reboot -i'.\r\n[linuxprobe@linuxprobe ~]$ sudo reboot<\/pre>\n

\u8bf7\u540c\u5b66\u4eec\u4ed4\u7ec6\u7559\u610f\u4e0a\u9762\u7684\u7528\u6237\u8eab\u4efd\u53d8\u6362\uff0cvisudo\u547d\u4ee4\u53ea\u6709root\u7ba1\u7406\u5458\u624d\u53ef\u4ee5\u6267\u884c\uff0c\u666e\u901a\u7528\u6237\u5728\u4f7f\u7528\u65f6\u4f1a\u63d0\u793a\u6743\u9650\u4e0d\u8db3\u3002<\/p>\n

\u51fa\u73b0\u95ee\u9898?\u5927\u80c6\u63d0\u95ee!<\/strong><\/span><\/p>\n

\u56e0\u8bfb\u8005\u4eec\u786c\u4ef6\u4e0d\u540c\u6216\u64cd\u4f5c\u9519\u8bef\u90fd\u53ef\u80fd\u5bfc\u81f4\u5b9e\u9a8c\u914d\u7f6e\u51fa\u9519\uff0c\u8bf7\u8010\u5fc3\u518d\u4ed4\u7ec6\u770b\u770b\u64cd\u4f5c\u6b65\u9aa4\u5427\uff0c\u4e0d\u8981\u6c14\u9981~<\/p>\n

Linux\u6280\u672f\u4ea4\u6d41\u5b66\u4e60\u8bf7\u52a0\u8bfb\u8005\u7fa4\uff08\u63a8\u8350<\/span><\/strong>\uff09\uff1ahttps:\/\/lrxjmw.cn\/club<\/a><\/p>\n

*\u672c\u7fa4\u7279\u8272\uff1a\u786e\u4fdd\u6bcf\u4e00\u4f4d\u7fa4\u53cb\u90fd\u662f\u300aLinux\u5c31\u8be5\u8fd9\u4e48\u5b66\u300b\u7684\u8bfb\u8005\uff0c\u7b54\u7591\u66f4\u6709\u9488\u5bf9\u6027\uff0c\u4e0d\u5b9a\u671f\u9886\u53d6\u5b9a\u5236\u793c\u54c1\u3002<\/p><\/blockquote>\n

\u672c\u7ae0\u8282\u7684\u590d\u4e60\u4f5c\u4e1a<\/span>(\u7b54\u6848\u5c31\u5728\u95ee\u9898\u7684\u4e0b\u4e00\u884c\u54e6\uff0c\u7528\u9f20\u6807\u9009\u4e2d\u5373\u53ef\u770b\u5230\u7684~)<\/strong><\/span><\/p>\n

1\uff0e\u5728RHEL 8\u7cfb\u7edf\u4e2d\uff0croot\u7ba1\u7406\u5458\u662f\u8c01\uff1f<\/p>\n

\u7b54\uff1a<\/strong>\u662fUID\u4e3a0\u7684\u7528\u6237\uff0c\u662f\u6743\u9650\u6700\u5927\u3001\u9650\u5236\u6700\u5c0f\u7684\u7ba1\u7406\u5458\u3002<\/span><\/p>\n

2\uff0e\u5982\u4f55\u4f7f\u7528Linux\u7cfb\u7edf\u7684\u547d\u4ee4\u884c\u6765\u6dfb\u52a0\u548c\u5220\u9664\u7528\u6237\uff1f<\/p>\n

\u7b54\uff1a<\/strong>\u6dfb\u52a0\u548c\u5220\u9664\u7528\u6237\u7684\u547d\u4ee4\u5206\u522b\u662fuseradd\u4e0euserdel\u3002<\/span><\/p>\n

3\uff0e\u82e5\u67d0\u4e2a\u6587\u4ef6\u7684\u6240\u6709\u8005\u5177\u6709\u6587\u4ef6\u7684\u8bfb\/\u5199\/\u6267\u884c\u6743\u9650\uff0c\u5176\u4f59\u4eba\u4ec5\u6709\u8bfb\u6743\u9650\uff0c\u90a3\u4e48\u7528\u6570\u5b57\u6cd5\u8868\u793a\u5e94\u8be5\u662f\u4ec0\u4e48?<\/p>\n

\u7b54\uff1a<\/strong>\u6240\u6709\u8005\u6743\u9650\u4e3arwx\uff0c\u6240\u5c5e\u7ec4\u548c\u5176\u4ed6\u4eba\u7684\u6743\u9650\u4e3ar--\uff0c\u56e0\u6b64\u6570\u5b57\u6cd5\u8868\u793a\u5e94\u8be5\u662f744\u3002<\/span><\/p>\n

4\uff0e\u67d0\u6587\u4ef6\u7684\u5b57\u7b26\u6743\u9650\u4e3arwxrw-r--\uff0c\u90a3\u4e48\u5bf9\u5e94\u7684\u6570\u5b57\u6cd5\u6743\u9650\u5e94\u8be5\u662f\u591a\u5c11\uff1f<\/p>\n

\u7b54\uff1a<\/strong>\u6570\u5b57\u6cd5\u6743\u9650\u5e94\u8be5\u662f764\u3002<\/span><\/p>\n

5\uff0e\u67d0\u94fe\u63a5\u6587\u4ef6\u7684\u6743\u9650\u7528\u6570\u5b57\u6cd5\u8868\u793a\u4e3a755\uff0c\u90a3\u4e48\u76f8\u5e94\u7684\u5b57\u7b26\u6cd5\u8868\u793a\u662f\u4ec0\u4e48\u5462\uff1f<\/p>\n

\u7b54\uff1a<\/strong>\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u4e0d\u540c\u6587\u4ef6\u5177\u6709\u4e0d\u540c\u7684\u7c7b\u578b\uff0c\u56e0\u6b64\u8fd9\u91cc\u5e94\u5199\u6210lrwxr-xr-x\u3002<\/span><\/p>\n

6\uff0e\u5982\u679c\u5e0c\u671b\u7528\u6237\u6267\u884c\u67d0\u547d\u4ee4\u65f6\u4e34\u65f6\u62e5\u6709\u8be5\u547d\u4ee4\u6240\u6709\u8005\u7684\u6743\u9650\uff0c\u5e94\u8be5\u8bbe\u7f6e\u4ec0\u4e48\u7279\u6b8a\u6743\u9650\uff1f<\/p>\n

\u7b54\uff1a<\/strong>\u7279\u6b8a\u6743\u9650\u4e2d\u7684SUID\u3002<\/span><\/p>\n

7\uff0e\u82e5\u5bf9\u6587\u4ef6\u8bbe\u7f6e\u4e86\u9690\u85cf\u6743\u9650\uff08+i\u53c2\u6570\uff09\uff0c\u5219\u610f\u5473\u7740\u4ec0\u4e48\uff1f<\/p>\n

\u7b54\uff1a<\/strong>\u65e0\u6cd5\u5bf9\u6587\u4ef6\u8fdb\u884c\u4fee\u6539\uff1b\u82e5\u5bf9\u76ee\u5f55\u8bbe\u7f6e\u4e86\u8be5\u53c2\u6570\uff0c\u5219\u4ec5\u80fd\u4fee\u6539\u5176\u4e2d\u7684\u5b50\u6587\u4ef6\u5185\u5bb9\u800c\u4e0d\u80fd\u65b0\u5efa\u6216\u5220\u9664\u6587\u4ef6\u3002<\/span><\/p>\n

8\uff0e\u4f7f\u7528\u8bbf\u95ee\u63a7\u5236\u5217\u8868\uff08ACL\uff09\u6765\u9650\u5236linuxprobe\u7528\u6237\u7ec4\uff0c\u4f7f\u5f97\u8be5\u7ec4\u4e2d\u7684\u6240\u6709\u6210\u5458\u4e0d\u5f97\u5728\/tmp\u76ee\u5f55\u4e2d\u5199\u5165\u5185\u5bb9\u3002<\/p>\n

\u7b54\uff1a<\/strong>\u60f3\u8981\u8bbe\u7f6e\u7528\u6237\u7ec4\u7684ACL\uff0c\u5219\u9700\u8981\u628au\u6539\u6210g\uff0c\u5373setfacl -Rm g:linuxprobe:r-x \/tmp\u3002<\/span><\/p>\n

9\uff0e\u5f53\u666e\u901a\u7528\u6237\u4f7f\u7528sudo\u547d\u4ee4\u65f6\u662f\u5426\u9700\u8981\u9a8c\u8bc1\u5bc6\u7801\uff1f<\/p>\n

\u7b54\uff1a<\/strong>\u7cfb\u7edf\u5728\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u9700\u8981\u9a8c\u8bc1\u5f53\u524d\u767b\u5f55\u7528\u6237\u7684\u5bc6\u7801\uff0c\u82e5\u4e0d\u60f3\u9a8c\u8bc1\uff0c\u53ef\u6dfb\u52a0NOPASSWD\u53c2\u6570\u3002<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"

\u7ae0\u8282\u7b80\u8ff0\uff1a Linux\u662f\u4e00\u4e2a\u591a\u7528\u6237\u3001\u591a\u4efb\u52a1\u7684\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5177\u6709\u5f88\u597d\u7684\u7a33\u5b9a\u6027\u4e0e\u5b89\u5168\u6027\uff0c\u5728\u5e55\u540e\u4fdd\u969cLinux\u7cfb\u7edf\u7684\u5b89\u5168 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[559],"tags":[],"class_list":["post-181464","post","type-post","status-publish","format-standard","hentry","category-rhel8"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/181464","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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=181464"}],"version-history":[{"count":111,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/181464\/revisions"}],"predecessor-version":[{"id":248462,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/181464\/revisions\/248462"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=181464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=181464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=181464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}