{"id":61743,"date":"2025-04-29T11:37:15","date_gmt":"2025-04-29T03:37:15","guid":{"rendered":"https:\/\/fwq.ai\/blog\/61743\/"},"modified":"2025-04-29T11:37:15","modified_gmt":"2025-04-29T03:37:15","slug":"%e9%ab%98%e7%ba%a7-linux-shell-%e8%84%9a%e6%9c%ac%e7%bc%96%e7%a8%8b%e7%b3%bb%e5%88%97%ef%bc%88%e4%b8%80%ef%bc%89-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/61743\/","title":{"rendered":"\u9ad8\u7ea7 Linux Shell \u811a\u672c\u7f16\u7a0b\u7cfb\u5217\uff08\u4e00\uff09"},"content":{"rendered":"<p>unix shell \u63d0\u4f9b\u4e86\u4e00\u4e2a\u975e\u5e38\u5f3a\u5927\u4e14\u53ef\u6269\u5c55\u7684\u811a\u672c\u6846\u67b6\u3002\u8bb8\u591a\u9ad8\u7ea7\u673a\u5236\u5141\u8bb8\u4f7f\u7528\u5185\u7f6e\u547d\u4ee4\u7f16\u5199\u66f4\u590d\u6742\u7684\u811a\u672c\u3002<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/164\/168891633078184.jpg\" class=\"aligncenter\" title=\"\u9ad8\u7ea7 Linux Shell \u811a\u672c\u7f16\u7a0b\u7cfb\u5217\uff08\u4e00\uff09\u63d2\u56fe\" alt=\"\u9ad8\u7ea7 Linux Shell \u811a\u672c\u7f16\u7a0b\u7cfb\u5217\uff08\u4e00\uff09\u63d2\u56fe\" \/><\/p>\n<h4>1\u3001Shell \u811a\u672c<\/h4>\n<p>\u7f16\u5199\u4e00\u4e2a\u540d\u4e3a linuxmi.sh \u7684bash\u811a\u672c\uff0c\u5f53\u4f7f\u7528\u4e09\u4e2a\u7ed9\u5b9a\u53c2\u6570\uff08\u4e00\u4e2a\u662f\u76ee\u5f55\u540d\u79f0\uff0c\u7b2c\u4e8c\u4e2a\u662f\u8d77\u59cb\u76ee\u5f55\u6570\u91cf\uff0c\u7b2c\u4e09\u4e2a\u662f\u7ed3\u675f\u76ee\u5f55\u6570\u91cf\uff09\u6267\u884c\u8be5\u811a\u672c\u65f6\uff0c\u5b83\u5c06\u521b\u5efa\u6307\u5b9a\u6570\u91cf\u7684\u76ee\u5f55\uff0c\u76ee\u5f55\u540d\u79f0\u662f\u52a8\u6001\u751f\u6210\u7684\u3002<\/p>\n<p>\u4ee3\u7801\u5982\u4e0b\u56fe\uff1a&nbsp;<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/164\/168891633061812.png\" class=\"aligncenter\" title=\"\u9ad8\u7ea7 Linux Shell \u811a\u672c\u7f16\u7a0b\u7cfb\u5217\uff08\u4e00\uff09\u63d2\u56fe1\" alt=\"\u9ad8\u7ea7 Linux Shell \u811a\u672c\u7f16\u7a0b\u7cfb\u5217\uff08\u4e00\uff09\u63d2\u56fe1\" \/><\/p>\n<p>\u8f93\u51fa\u5982\u4e0b\u56fe\uff1a<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/164\/168891633168351.png\" class=\"aligncenter\" title=\"\u9ad8\u7ea7 Linux Shell \u811a\u672c\u7f16\u7a0b\u7cfb\u5217\uff08\u4e00\uff09\u63d2\u56fe2\" alt=\"\u9ad8\u7ea7 Linux Shell \u811a\u672c\u7f16\u7a0b\u7cfb\u5217\uff08\u4e00\uff09\u63d2\u56fe2\" \/><\/p>\n<h4>2\u3001\u521b\u5efa\u4e00\u4e2a\u811a\u672c\u6765\u5907\u4efd\u5230\u76ee\u524d\u4e3a\u6b62\u5b8c\u6210\u7684\u6240\u6709\u5de5\u4f5c<\/h4>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/164\/168891633159779.png\" class=\"aligncenter\" title=\"\u9ad8\u7ea7 Linux Shell \u811a\u672c\u7f16\u7a0b\u7cfb\u5217\uff08\u4e00\uff09\u63d2\u56fe3\" alt=\"\u9ad8\u7ea7 Linux Shell \u811a\u672c\u7f16\u7a0b\u7cfb\u5217\uff08\u4e00\uff09\u63d2\u56fe3\" \/><\/p>\n<h4>3\u3001\u4e86\u89e3Cron\u548cCrontab\uff0c\u4ee5\u81ea\u52a8\u5316\u5907\u4efd\u811a\u672c<\/h4>\n<p>Cron\u662fLinux\u4e2d\u8fd0\u884c\u5b9a\u65f6\u4f5c\u4e1a\u7684\u5e94\u7528\u7a0b\u5e8f\u3002Cron\u662f\u4e00\u4e2a\u8fd0\u884c\u5728\u6240\u6709Linux\u7cfb\u7edf\u4e0a\u7684\u7cfb\u7edf\u5b88\u62a4\u7a0b\u5e8f\uff0c\u5b83\u8d1f\u8d23\u76d1\u6d4b\u5b9a\u65f6\u4efb\u52a1\u5e76\u6309\u7167\u9884\u5b9a\u7684\u65f6\u95f4\u95f4\u9694\u6267\u884c\u5b83\u4eec\u3002Crontab\u662f\u7531Cron\u4f7f\u7528\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u7528\u4e8e\u8fd0\u884c\u670d\u52a1\u3002Crontab\u4fdd\u5b58\u4e86\u54ea\u4e2a\u670d\u52a1\u5e94\u8be5\u8fd0\u884c\u4ee5\u53ca\u4f55\u65f6\u8fd0\u884c\u7684\u914d\u7f6e\u3002\u670d\u52a1\u662f\u4e00\u4e2a\u53ef\u7528\u4e8e\u6267\u884c\u811a\u672c\u3001\u5e94\u7528\u7a0b\u5e8f\u548c\u5176\u4ed6\u547d\u4ee4\u7684\u6267\u884c\u8def\u5f84\u3002<\/p>\n<h4>4\u3001\u4e86\u89e3\u7528\u6237\u7ba1\u7406<\/h4>\n<p>\u7528\u6237\u7ba1\u7406\u662f\u5728\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u7ba1\u7406\u4e0d\u540c\u7528\u6237\u8d26\u6237\u53ca\u5176\u76f8\u5e94\u6743\u9650\u7684\u8fc7\u7a0b\u3002\u6211\u4eec\u53ef\u4ee5\u5728Linux\u4e0a\u521b\u5efa\u4e0d\u540c\u7684\u7528\u6237\u8d26\u6237\uff0c\u5e76\u5c06\u5b83\u4eec\u5206\u7ec4\uff0c\u4ee5\u66f4\u6539\u6216\u5220\u9664\u5b83\u4eec\u7684\u6743\u9650\u96c6\u3002\u7528\u6237\u662fLinux\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u53ef\u4ee5\u64cd\u4f5c\u6587\u4ef6\u548c\u6267\u884c\u5176\u4ed6\u64cd\u4f5c\u7684\u5b9e\u4f53\u3002\u6bcf\u4e2a\u7528\u6237\u88ab\u5206\u914d\u4e00\u4e2a\u5728\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u552f\u4e00\u7684ID\u3002\u5728\u5b89\u88c5\u64cd\u4f5c\u7cfb\u7edf\u540e\uff0cID 0\u88ab\u5206\u914d\u7ed9root\u7528\u6237\uff0c\u800cID 1\u5230999\uff08\u5305\u62ec\uff09\u88ab\u5206\u914d\u7ed9\u7cfb\u7edf\u7528\u6237\uff0c\u56e0\u6b64\u672c\u5730\u7528\u6237\u7684ID\u4ece1000\u5f00\u59cb\u3002<\/p>\n<p>\u7ba1\u7406\u7528\u6237\uff1a<\/p>\n<p>1\uff09\u521b\u5efa\u7528\u6237\uff1a\u8981\u521b\u5efa\u4e00\u4e2a\u65b0\u7528\u6237\uff0c\u8bf7\u4f7f\u7528useradd\u547d\u4ee4\uff1a<\/p>\n<pre>sudo useradd &lt;user_name&gt;&lt;\/user_name&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>2\uff09\u8bbe\u7f6e\u5bc6\u7801\uff1a\u5728\u521b\u5efa\u7528\u6237\u4e4b\u540e\uff0c\u60a8\u9700\u8981\u8bbe\u7f6e\u5bc6\u7801\uff0c\u8bf7\u4f7f\u7528passwd\u547d\u4ee4<\/p>\n<pre>sudo passwd &lt;user_name&gt;&lt;\/user_name&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>3) \u82e5\u8981\u4fee\u6539Linux\u7528\u6237\uff0c\u8bf7\u8fd0\u7528usermod\u6307\u4ee4\u3002\u7528\u6237\u4fee\u6539\u548c\u6dfb\u52a0\u547d\u4ee4\u76f8\u4f3c\uff0cusermod\u547d\u4ee4\u53ef\u4f7f\u7528\u76f8\u540c\u53c2\u6570\u6765\u8bbe\u7f6e\u7528\u6237\u5b57\u6bb5\uff1a<\/p>\n<pre>sudo usermod &lt;user_name&gt;&lt;\/user_name&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>4\uff09\u5220\u9664\u7528\u6237\uff1a\u8981\u5220\u9664Linux\u7528\u6237\uff0c\u8bf7\u4f7f\u7528userdel\u547d\u4ee4\uff1a<\/p>\n<pre>userdel &lt;user_name&gt;&lt;\/user_name&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>5\uff09\u521b\u5efa2\u4e2a\u7528\u6237\u5e76\u4ec5\u663e\u793a\u5b83\u4eec\u7684\u7528\u6237\u540d\u3002<\/p>\n<p>\u521b\u5efa\u4e862\u4e2a\u7528\u6237\uff1a<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/164\/168891633124585.png\" class=\"aligncenter\" title=\"\u9ad8\u7ea7 Linux Shell \u811a\u672c\u7f16\u7a0b\u7cfb\u5217\uff08\u4e00\uff09\u63d2\u56fe4\" alt=\"\u9ad8\u7ea7 Linux Shell \u811a\u672c\u7f16\u7a0b\u7cfb\u5217\uff08\u4e00\uff09\u63d2\u56fe4\" \/><\/p>\n<p>\u663e\u793a2\u4e2a\u7528\u6237\uff1a<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/164\/168891633148299.png\" class=\"aligncenter\" title=\"\u9ad8\u7ea7 Linux Shell \u811a\u672c\u7f16\u7a0b\u7cfb\u5217\uff08\u4e00\uff09\u63d2\u56fe5\" alt=\"\u9ad8\u7ea7 Linux Shell \u811a\u672c\u7f16\u7a0b\u7cfb\u5217\uff08\u4e00\uff09\u63d2\u56fe5\" \/><\/p>\n<p>\u8981\u663e\u793a\u7528\u6237\u5217\u8868\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>cat \/etc\/passwd<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u9ad8\u7ea7 Linux Shell \u811a\u672c\u7f16\u7a0b\u7cfb\u5217\uff08\u4e00\uff09\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8FDCServers\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>unix shell \u63d0\u4f9b\u4e86\u4e00\u4e2a\u975e\u5e38\u5f3a\u5927\u4e14\u53ef\u6269\u5c55\u7684\u811a\u672c\u6846\u67b6\u3002\u8bb8\u591a\u9ad8\u7ea7\u673a\u5236\u5141\u8bb8\u4f7f\u7528\u5185\u7f6e\u547d\u4ee4\u7f16\u5199\u66f4\u590d\u6742\u7684\u811a\u672c\u3002 1\u3001Shell \u811a\u672c \u7f16\u5199\u4e00\u4e2a\u540d\u4e3a linuxmi.sh \u7684bash\u811a\u672c\uff0c\u5f53\u4f7f\u7528\u4e09\u4e2a\u7ed9\u5b9a\u53c2\u6570\uff08\u4e00\u4e2a\u662f\u76ee\u5f55\u540d\u79f0\uff0c\u7b2c\u4e8c\u4e2a\u662f\u8d77\u59cb\u76ee\u5f55\u6570\u91cf\uff0c\u7b2c\u4e09\u4e2a\u662f\u7ed3\u675f\u76ee\u5f55\u6570\u91cf\uff09\u6267\u884c\u8be5\u811a\u672c\u65f6\uff0c\u5b83\u5c06\u521b\u5efa\u6307\u5b9a\u6570\u91cf\u7684\u76ee\u5f55\uff0c\u76ee\u5f55\u540d\u79f0\u662f\u52a8\u6001\u751f\u6210\u7684\u3002 \u4ee3\u7801\u5982\u4e0b\u56fe\uff1a&nbsp; \u8f93\u51fa\u5982\u4e0b\u56fe\uff1a 2\u3001\u521b\u5efa\u4e00\u4e2a\u811a\u672c\u6765\u5907\u4efd\u5230\u76ee\u524d\u4e3a\u6b62\u5b8c\u6210\u7684\u6240\u6709\u5de5\u4f5c 3\u3001\u4e86\u89e3Cron\u548cCrontab\uff0c\u4ee5\u81ea\u52a8\u5316\u5907\u4efd\u811a\u672c Cron\u662fLinux\u4e2d\u8fd0\u884c\u5b9a\u65f6\u4f5c\u4e1a\u7684\u5e94\u7528\u7a0b\u5e8f\u3002Cron\u662f\u4e00\u4e2a\u8fd0\u884c\u5728\u6240\u6709Linux\u7cfb\u7edf\u4e0a\u7684\u7cfb\u7edf\u5b88\u62a4\u7a0b\u5e8f\uff0c\u5b83\u8d1f\u8d23\u76d1\u6d4b\u5b9a\u65f6\u4efb\u52a1\u5e76\u6309\u7167\u9884\u5b9a\u7684\u65f6\u95f4\u95f4\u9694\u6267\u884c\u5b83\u4eec\u3002Crontab\u662f\u7531Cron\u4f7f\u7528\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u7528\u4e8e\u8fd0\u884c\u670d\u52a1\u3002Crontab\u4fdd\u5b58\u4e86\u54ea\u4e2a\u670d\u52a1\u5e94\u8be5\u8fd0\u884c\u4ee5\u53ca\u4f55\u65f6\u8fd0\u884c\u7684\u914d\u7f6e\u3002\u670d\u52a1\u662f\u4e00\u4e2a\u53ef\u7528\u4e8e\u6267\u884c\u811a\u672c\u3001\u5e94\u7528\u7a0b\u5e8f\u548c\u5176\u4ed6\u547d\u4ee4\u7684\u6267\u884c\u8def\u5f84\u3002 4\u3001\u4e86\u89e3\u7528\u6237\u7ba1\u7406 \u7528\u6237\u7ba1\u7406\u662f\u5728\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u7ba1\u7406\u4e0d\u540c\u7528\u6237\u8d26\u6237\u53ca\u5176\u76f8\u5e94\u6743\u9650\u7684\u8fc7\u7a0b\u3002\u6211\u4eec\u53ef\u4ee5\u5728Linux\u4e0a\u521b\u5efa\u4e0d\u540c\u7684\u7528\u6237\u8d26\u6237\uff0c\u5e76\u5c06\u5b83\u4eec\u5206\u7ec4\uff0c\u4ee5\u66f4\u6539\u6216\u5220\u9664\u5b83\u4eec\u7684\u6743\u9650\u96c6\u3002\u7528\u6237\u662fLinux\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u53ef\u4ee5\u64cd\u4f5c\u6587\u4ef6\u548c\u6267\u884c\u5176\u4ed6\u64cd\u4f5c\u7684\u5b9e\u4f53\u3002\u6bcf\u4e2a\u7528\u6237\u88ab\u5206\u914d\u4e00\u4e2a\u5728\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u552f\u4e00\u7684ID\u3002\u5728\u5b89\u88c5\u64cd\u4f5c\u7cfb\u7edf\u540e\uff0cID 0\u88ab\u5206\u914d\u7ed9root\u7528\u6237\uff0c\u800cID 1\u5230999\uff08\u5305\u62ec\uff09\u88ab\u5206\u914d\u7ed9\u7cfb\u7edf\u7528\u6237\uff0c\u56e0\u6b64\u672c\u5730\u7528\u6237\u7684ID\u4ece1000\u5f00\u59cb\u3002 \u7ba1\u7406\u7528\u6237\uff1a 1\uff09\u521b\u5efa\u7528\u6237\uff1a\u8981\u521b\u5efa\u4e00\u4e2a\u65b0\u7528\u6237\uff0c\u8bf7\u4f7f\u7528useradd\u547d\u4ee4\uff1a sudo useradd &lt;user_name&gt;&lt;\/user_name&gt; \u767b\u5f55\u540e\u590d\u5236 2\uff09\u8bbe\u7f6e\u5bc6\u7801\uff1a\u5728\u521b\u5efa\u7528\u6237\u4e4b\u540e\uff0c\u60a8\u9700\u8981\u8bbe\u7f6e\u5bc6\u7801\uff0c\u8bf7\u4f7f\u7528passwd\u547d\u4ee4 sudo passwd &lt;user_name&gt;&lt;\/user_name&gt; \u767b\u5f55\u540e\u590d\u5236 3) \u82e5\u8981\u4fee\u6539Linux\u7528\u6237\uff0c\u8bf7\u8fd0\u7528usermod\u6307\u4ee4\u3002\u7528\u6237\u4fee\u6539\u548c\u6dfb\u52a0\u547d\u4ee4\u76f8\u4f3c\uff0cusermod\u547d\u4ee4\u53ef\u4f7f\u7528\u76f8\u540c\u53c2\u6570\u6765\u8bbe\u7f6e\u7528\u6237\u5b57\u6bb5\uff1a sudo usermod &lt;user_name&gt;&lt;\/user_name&gt; \u767b\u5f55\u540e\u590d\u5236 4\uff09\u5220\u9664\u7528\u6237\uff1a\u8981\u5220\u9664Linux\u7528\u6237\uff0c\u8bf7\u4f7f\u7528userdel\u547d\u4ee4\uff1a userdel &lt;user_name&gt;&lt;\/user_name&gt; \u767b\u5f55\u540e\u590d\u5236 5\uff09\u521b\u5efa2\u4e2a\u7528\u6237\u5e76\u4ec5\u663e\u793a\u5b83\u4eec\u7684\u7528\u6237\u540d\u3002 \u521b\u5efa\u4e862\u4e2a\u7528\u6237\uff1a \u663e\u793a2\u4e2a\u7528\u6237\uff1a \u8981\u663e\u793a\u7528\u6237\u5217\u8868\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a cat \/etc\/passwd \u767b\u5f55\u540e\u590d\u5236 \u4ee5\u4e0a\u5c31\u662f\u9ad8\u7ea7 Linux Shell \u811a\u672c\u7f16\u7a0b\u7cfb\u5217\uff08\u4e00\uff09\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8FDCServers\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-61743","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/61743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=61743"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/61743\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=61743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=61743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=61743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}