{"id":4633,"date":"2025-11-06T10:20:43","date_gmt":"2025-11-06T02:20:43","guid":{"rendered":"https:\/\/silubaba.com.cn\/?p=4633"},"modified":"2025-11-06T10:22:52","modified_gmt":"2025-11-06T02:22:52","slug":"linux-%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%ae%a1%e7%90%86%e7%b3%bb%e7%bb%9f%e6%96%b9%e6%a1%88%ef%bc%88python%ef%bc%89","status":"publish","type":"post","link":"https:\/\/silubaba.com.cn\/?p=4633","title":{"rendered":"Linux \u670d\u52a1\u5668\u7ba1\u7406\u7cfb\u7edf\u65b9\u6848\uff08Python\uff09"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">\u5b98\u65b9\u7f51  <a href=\"http:\/\/linux.silubaba.com.cn\" target=\"_blank\" rel=\"noopener\" title=\"\">linux.silubaba.com.cn<\/a><\/h1>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"647\" src=\"https:\/\/silubaba.com.cn\/wp-content\/uploads\/2025\/11\/Screen-Shot-2025-11-06-at-10.18.37-1024x647.png\" alt=\"\" class=\"wp-image-4636\" srcset=\"https:\/\/silubaba.com.cn\/wp-content\/uploads\/2025\/11\/Screen-Shot-2025-11-06-at-10.18.37-1024x647.png 1024w, https:\/\/silubaba.com.cn\/wp-content\/uploads\/2025\/11\/Screen-Shot-2025-11-06-at-10.18.37-300x189.png 300w, https:\/\/silubaba.com.cn\/wp-content\/uploads\/2025\/11\/Screen-Shot-2025-11-06-at-10.18.37-768x485.png 768w, https:\/\/silubaba.com.cn\/wp-content\/uploads\/2025\/11\/Screen-Shot-2025-11-06-at-10.18.37-1536x970.png 1536w, https:\/\/silubaba.com.cn\/wp-content\/uploads\/2025\/11\/Screen-Shot-2025-11-06-at-10.18.37.png 2036w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"551\" src=\"https:\/\/silubaba.com.cn\/wp-content\/uploads\/2025\/11\/Screen-Shot-2025-11-06-at-10.19.10-1024x551.png\" alt=\"\" class=\"wp-image-4634\" srcset=\"https:\/\/silubaba.com.cn\/wp-content\/uploads\/2025\/11\/Screen-Shot-2025-11-06-at-10.19.10-1024x551.png 1024w, https:\/\/silubaba.com.cn\/wp-content\/uploads\/2025\/11\/Screen-Shot-2025-11-06-at-10.19.10-300x162.png 300w, https:\/\/silubaba.com.cn\/wp-content\/uploads\/2025\/11\/Screen-Shot-2025-11-06-at-10.19.10-768x413.png 768w, https:\/\/silubaba.com.cn\/wp-content\/uploads\/2025\/11\/Screen-Shot-2025-11-06-at-10.19.10-1536x827.png 1536w, https:\/\/silubaba.com.cn\/wp-content\/uploads\/2025\/11\/Screen-Shot-2025-11-06-at-10.19.10.png 1980w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e00\u3001\u7cfb\u7edf\u76ee\u6807<\/h2>\n\n\n\n<p>\u6784\u5efa\u4e00\u5957\u57fa\u4e8e Python \u7684\u96c6\u6210\u5316 Linux \u670d\u52a1\u5668\u7ba1\u7406\u7cfb\u7edf\uff0c\u5b9e\u73b0\u5bf9\u670d\u52a1\u5668\u5168\u529f\u80fd\u7684\u7edf\u4e00\u7ba1\u63a7\uff0c\u6db5\u76d6\u6587\u4ef6\u64cd\u4f5c\u3001SSH \u914d\u7f6e\u3001\u7f51\u7edc\u7ba1\u7406\u3001Web \u670d\u52a1\uff08Apache\/Nginx\uff09\u3001\u9632\u706b\u5899\uff08UFW\uff09\u53ca MySQL \u6570\u636e\u5e93\u7b49\u6838\u5fc3\u6a21\u5757\uff0c\u652f\u6301\u672c\u5730\u53ca\u8fdc\u7a0b\u670d\u52a1\u5668\u7ba1\u7406\uff0c\u63d0\u4f9b\u76f4\u89c2\u7684\u64cd\u4f5c\u63a5\u53e3\uff08CLI \u6216 Web\uff09\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3001\u6838\u5fc3\u529f\u80fd\u8303\u56f4<\/h2>\n\n\n\n<p>\u8986\u76d6 Linux \u670d\u52a1\u5668\u7ba1\u7406\u5168\u573a\u666f\uff0c\u5177\u4f53\u5305\u62ec\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u6587\u4ef6\u7ba1\u7406<\/strong>\uff1a\u672c\u5730\/\u8fdc\u7a0b\u6587\u4ef6\u7684\u521b\u5efa\u3001\u5220\u9664\u3001\u590d\u5236\u3001\u79fb\u52a8\u3001\u6743\u9650\u4fee\u6539\u3001\u538b\u7f29\/\u89e3\u538b\u3001\u5185\u5bb9\u7f16\u8f91\u3001\u78c1\u76d8\u5360\u7528\u5206\u6790\u7b49\u3002<\/li>\n\n\n\n<li><strong>SSH \u7ba1\u7406<\/strong>\uff1aSSH \u670d\u52a1\u72b6\u6001\u76d1\u63a7\u3001\u914d\u7f6e\u4fee\u6539\uff08\u7aef\u53e3\u3001\u5bc6\u94a5\u8ba4\u8bc1\u3001\u767b\u5f55\u9650\u5236\uff09\u3001\u7528\u6237\u5bc6\u94a5\u7ba1\u7406\u3001\u8fde\u63a5\u65e5\u5fd7\u5ba1\u8ba1\u3001\u6279\u91cf\u6267\u884c\u547d\u4ee4\u7b49\u3002<\/li>\n\n\n\n<li><strong>\u7f51\u7edc\u7ba1\u7406<\/strong>\uff1a\u7f51\u5361\u914d\u7f6e\uff08IP\u3001\u5b50\u7f51\u63a9\u7801\u3001\u7f51\u5173\uff09\u3001DNS \u8bbe\u7f6e\u3001\u7aef\u53e3\u76d1\u542c\u68c0\u6d4b\u3001\u7f51\u7edc\u6d41\u91cf\u76d1\u63a7\u3001\u8def\u7531\u8868\u7ba1\u7406\u3001\u9632\u706b\u5899\u89c4\u5219\u5173\u8054\u7b49\u3002<\/li>\n\n\n\n<li><strong>Web \u670d\u52a1\u7ba1\u7406<\/strong>\uff1a<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Apache\uff1a\u670d\u52a1\u542f\u505c\/\u91cd\u542f\u3001\u865a\u62df\u4e3b\u673a\u914d\u7f6e\u3001\u6a21\u5757\u7ba1\u7406\u3001\u65e5\u5fd7\u5206\u6790\u3001\u72b6\u6001\u76d1\u63a7\u3002<\/li>\n\n\n\n<li>Nginx\uff1a\u670d\u52a1\u63a7\u5236\u3001\u914d\u7f6e\u6587\u4ef6\u6821\u9a8c\u3001\u865a\u62df\u4e3b\u673a\u7ba1\u7406\u3001\u53cd\u5411\u4ee3\u7406\u914d\u7f6e\u3001\u6027\u80fd\u53c2\u6570\u8c03\u4f18\u3002<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u9632\u706b\u5899\uff08UFW\uff09\u7ba1\u7406<\/strong>\uff1a\u9632\u706b\u5899\u72b6\u6001\u5207\u6362\u3001\u7aef\u53e3\u653e\u884c\/\u5c01\u7981\u3001IP \u9ed1\u767d\u540d\u5355\u8bbe\u7f6e\u3001\u89c4\u5219\u5907\u4efd\/\u6062\u590d\u3001\u72b6\u6001\u76d1\u63a7\u3002<\/li>\n\n\n\n<li><strong>MySQL \u7ba1\u7406<\/strong>\uff1a\u670d\u52a1\u542f\u505c\u3001\u7528\u6237\u6743\u9650\u7ba1\u7406\u3001\u6570\u636e\u5e93\u5907\u4efd\/\u6062\u590d\u3001\u6027\u80fd\u53c2\u6570\u914d\u7f6e\u3001\u8fde\u63a5\u72b6\u6001\u76d1\u63a7\u3001\u65e5\u5fd7\u5206\u6790\u3002<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u3001\u7cfb\u7edf\u67b6\u6784\u8bbe\u8ba1<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u6574\u4f53\u67b6\u6784<\/h3>\n\n\n\n<p>\u91c7\u7528\u6a21\u5757\u5316\u5206\u5c42\u8bbe\u8ba1\uff0c\u5206\u4e3a\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u57fa\u7840\u5c42<\/strong>\uff1a\u8d1f\u8d23\u8fde\u63a5\u7ba1\u7406\uff08\u672c\u5730\/SSH \u4f1a\u8bdd\uff09\u3001\u6743\u9650\u6821\u9a8c\u3001\u65e5\u5fd7\u8bb0\u5f55\u3001\u5f02\u5e38\u5904\u7406\u3002<\/li>\n\n\n\n<li><strong>\u529f\u80fd\u6a21\u5757\u5c42<\/strong>\uff1a\u6309\u7ba1\u7406\u5bf9\u8c61\u62c6\u5206\u72ec\u7acb\u6a21\u5757\uff08\u6587\u4ef6\u3001SSH\u3001\u7f51\u7edc\u7b49\uff09\uff0c\u6a21\u5757\u95f4\u4f4e\u8026\u5408\u3002<\/li>\n\n\n\n<li><strong>\u63a5\u53e3\u5c42<\/strong>\uff1a\u63d0\u4f9b CLI \u547d\u4ee4\u884c\u63a5\u53e3\uff08\u4f18\u5148\u5b9e\u73b0\uff09\uff0c\u9884\u7559 Web \u63a5\u53e3\u6269\u5c55\u80fd\u529b\u3002<\/li>\n\n\n\n<li><strong>\u6570\u636e\u5c42<\/strong>\uff1a\u5b58\u50a8\u670d\u52a1\u5668\u914d\u7f6e\u4fe1\u606f\u3001\u64cd\u4f5c\u65e5\u5fd7\u3001\u5907\u4efd\u7b56\u7565\u7b49\uff08\u652f\u6301\u672c\u5730\u6587\u4ef6\u6216\u8f7b\u91cf\u6570\u636e\u5e93\uff09\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u6a21\u5757\u5173\u7cfb<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6240\u6709\u529f\u80fd\u6a21\u5757\u4f9d\u8d56\u57fa\u7840\u5c42\u7684\u8fde\u63a5\u7ba1\u7406\u80fd\u529b\uff0c\u901a\u8fc7\u7edf\u4e00\u63a5\u53e3\u6267\u884c\u672c\u5730\/\u8fdc\u7a0b\u64cd\u4f5c\u3002<\/li>\n\n\n\n<li>\u529f\u80fd\u6a21\u5757\u95f4\u53ef\u4ea4\u53c9\u8c03\u7528\uff08\u5982\uff1aWeb \u670d\u52a1\u7ba1\u7406\u9700\u4f9d\u8d56\u9632\u706b\u5899\u6a21\u5757\u914d\u7f6e\u7aef\u53e3\u653e\u884c\uff09\u3002<\/li>\n\n\n\n<li>\u63a5\u53e3\u5c42\u805a\u5408\u6240\u6709\u6a21\u5757\u529f\u80fd\uff0c\u63d0\u4f9b\u7edf\u4e00\u7684\u7528\u6237\u4ea4\u4e92\u5165\u53e3\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u56db\u3001\u6a21\u5757\u8be6\u7ec6\u8bbe\u8ba1<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u57fa\u7840\u8fde\u63a5\u6a21\u5757<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u6838\u5fc3\u80fd\u529b<\/strong>\uff1a\u7ba1\u7406\u672c\u5730\u670d\u52a1\u5668\u76f4\u63a5\u64cd\u4f5c\u3001\u8fdc\u7a0b\u670d\u52a1\u5668 SSH \u8fde\u63a5\uff08\u652f\u6301\u5bc6\u7801\/\u5bc6\u94a5\u8ba4\u8bc1\uff09\u3001\u8fde\u63a5\u6c60\u7ef4\u62a4\u3001\u4f1a\u8bdd\u4fdd\u6301\u3002<\/li>\n\n\n\n<li><strong>\u5173\u952e\u7279\u6027<\/strong>\uff1a\u81ea\u52a8\u91cd\u8fde\u673a\u5236\u3001\u64cd\u4f5c\u8d85\u65f6\u63a7\u5236\u3001\u6743\u9650\u9a8c\u8bc1\uff08\u786e\u4fdd\u6267\u884c\u7528\u6237\u6709\u8db3\u591f\u6743\u9650\uff09\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u6587\u4ef6\u7ba1\u7406\u6a21\u5757<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u672c\u5730\u6587\u4ef6\u64cd\u4f5c<\/strong>\uff1a\u57fa\u4e8e Python \u5185\u7f6e\u6587\u4ef6\u64cd\u4f5c\u5e93\uff0c\u5b9e\u73b0\u57fa\u7840\u6587\u4ef6\/\u76ee\u5f55\u7ba1\u7406\u3001\u6743\u9650\u63a7\u5236\uff08\u6620\u5c04 Linux chmod\/chown\uff09\u3002<\/li>\n\n\n\n<li><strong>\u8fdc\u7a0b\u6587\u4ef6\u64cd\u4f5c<\/strong>\uff1a\u901a\u8fc7 SFTP \u534f\u8bae\u5b9e\u73b0\u6587\u4ef6\u4e0a\u4f20\/\u4e0b\u8f7d\uff0c\u6267\u884c\u8fdc\u7a0b\u547d\u4ee4\u5b9e\u73b0\u6743\u9650\u4fee\u6539\u3001\u538b\u7f29\uff08tar\/zip\uff09\u7b49\u3002<\/li>\n\n\n\n<li><strong>\u9ad8\u7ea7\u529f\u80fd<\/strong>\uff1a\u6587\u4ef6\u5dee\u5f02\u5bf9\u6bd4\u3001\u6279\u91cf\u6587\u4ef6\u64cd\u4f5c\u3001\u5927\u6587\u4ef6\u65ad\u70b9\u4f20\u8f93\u3001\u78c1\u76d8\u7a7a\u95f4\u544a\u8b66\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3. SSH \u7ba1\u7406\u6a21\u5757<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u670d\u52a1\u914d\u7f6e<\/strong>\uff1a\u8bfb\u53d6\/\u4fee\u6539 <code>\/etc\/ssh\/sshd_config<\/code>\uff0c\u652f\u6301\u7aef\u53e3\u53d8\u66f4\u3001\u7981\u7528\u5bc6\u7801\u767b\u5f55\u3001\u9650\u5236root\u767b\u5f55\u7b49\u914d\u7f6e\u9879\u3002<\/li>\n\n\n\n<li><strong>\u5bc6\u94a5\u7ba1\u7406<\/strong>\uff1a\u751f\u6210 SSH \u5bc6\u94a5\u5bf9\u3001\u5411\u8fdc\u7a0b\u670d\u52a1\u5668\u63a8\u9001\u516c\u94a5\uff08\u5b9e\u73b0\u514d\u5bc6\u767b\u5f55\uff09\u3001\u7ba1\u7406 <code>authorized_keys<\/code> \u6587\u4ef6\u3002<\/li>\n\n\n\n<li><strong>\u5ba1\u8ba1\u529f\u80fd<\/strong>\uff1a\u89e3\u6790 SSH \u767b\u5f55\u65e5\u5fd7\uff08<code>\/var\/log\/auth.log<\/code>\uff09\uff0c\u7edf\u8ba1\u767b\u5f55\u6b21\u6570\u3001\u5f02\u5e38\u767b\u5f55\u544a\u8b66\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">4. \u7f51\u7edc\u7ba1\u7406\u6a21\u5757<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u7f51\u5361\u914d\u7f6e<\/strong>\uff1a\u8bfb\u53d6\/\u4fee\u6539\u7f51\u7edc\u63a5\u53e3\u914d\u7f6e\u6587\u4ef6\uff08\u5982 <code>\/etc\/netplan\/<\/code> \u6216 <code>\/etc\/sysconfig\/network-scripts\/<\/code>\uff09\uff0c\u652f\u6301\u9759\u6001IP\/\u52a8\u6001IP\u5207\u6362\u3002<\/li>\n\n\n\n<li><strong>\u72b6\u6001\u76d1\u63a7<\/strong>\uff1a\u6267\u884c <code>ifconfig<\/code>\/<code>ip<\/code> \u547d\u4ee4\u83b7\u53d6\u7f51\u5361\u72b6\u6001\uff0c<code>netstat<\/code>\/<code>ss<\/code> \u67e5\u770b\u7aef\u53e3\u5360\u7528\uff0c<code>ping<\/code>\/<code>traceroute<\/code> \u68c0\u6d4b\u7f51\u7edc\u8fde\u901a\u6027\u3002<\/li>\n\n\n\n<li><strong>\u6d41\u91cf\u5206\u6790<\/strong>\uff1a\u901a\u8fc7 <code>iftop<\/code> \u6216\u89e3\u6790 <code>\/proc\/net\/dev<\/code> \u76d1\u63a7\u5b9e\u65f6\u6d41\u91cf\uff0c\u8bb0\u5f55\u6d41\u91cf\u5cf0\u503c\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">5. Web \u670d\u52a1\u7ba1\u7406\u6a21\u5757\uff08Apache\/Nginx\uff09<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u670d\u52a1\u63a7\u5236<\/strong>\uff1a\u901a\u8fc7 <code>systemctl<\/code> \u7ba1\u7406\u670d\u52a1\u542f\u505c\/\u91cd\u542f\/\u72b6\u6001\u67e5\u8be2\uff0c\u652f\u6301\u914d\u7f6e\u6587\u4ef6\u8bed\u6cd5\u6821\u9a8c\u3002<\/li>\n\n\n\n<li><strong>\u865a\u62df\u4e3b\u673a\u7ba1\u7406<\/strong>\uff1a\u521b\u5efa\/\u5220\u9664\u865a\u62df\u4e3b\u673a\u914d\u7f6e\u6587\u4ef6\u3001\u5173\u8054\u57df\u540d\u4e0e\u76ee\u5f55\u3001\u914d\u7f6e SSL \u8bc1\u4e66\u8def\u5f84\u3002<\/li>\n\n\n\n<li><strong>\u6027\u80fd\u76d1\u63a7<\/strong>\uff1a\u83b7\u53d6\u5f53\u524d\u8fde\u63a5\u6570\u3001\u8bf7\u6c42\u91cf\u3001\u9519\u8bef\u7387\uff08\u89e3\u6790\u8bbf\u95ee\u65e5\u5fd7\uff09\uff0c\u652f\u6301\u91cd\u542f\u7b56\u7565\uff08\u5982\u8bf7\u6c42\u91cf\u8fc7\u9ad8\u65f6\u81ea\u52a8\u91cd\u542f\uff09\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">6. \u9632\u706b\u5899\uff08UFW\uff09\u7ba1\u7406\u6a21\u5757<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u89c4\u5219\u7ba1\u7406<\/strong>\uff1a\u6dfb\u52a0\/\u5220\u9664\u7aef\u53e3\u5141\u8bb8\u89c4\u5219\uff08\u5982\u5141\u8bb8 80\/tcp\uff09\u3001IP \u9650\u5236\uff08\u5982\u7981\u6b62\u7279\u5b9aIP\u8bbf\u95ee\uff09\u3001\u89c4\u5219\u4f18\u5148\u7ea7\u8c03\u6574\u3002<\/li>\n\n\n\n<li><strong>\u72b6\u6001\u63a7\u5236<\/strong>\uff1a\u542f\u7528\/\u7981\u7528\u9632\u706b\u5899\u3001\u67e5\u770b\u5f53\u524d\u6d3b\u8dc3\u89c4\u5219\u3001\u4fdd\u5b58\/\u6062\u590d\u89c4\u5219\u914d\u7f6e\u3002<\/li>\n\n\n\n<li><strong>\u65e5\u5fd7\u5206\u6790<\/strong>\uff1a\u89e3\u6790 UFW \u65e5\u5fd7\uff0c\u7edf\u8ba1\u62e6\u622a\u8bb0\u5f55\u3001\u5f02\u5e38\u8bbf\u95ee\u6a21\u5f0f\u8bc6\u522b\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">7. MySQL \u7ba1\u7406\u6a21\u5757<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u670d\u52a1\u63a7\u5236<\/strong>\uff1a\u901a\u8fc7 <code>systemctl<\/code> \u7ba1\u7406 MySQL \u670d\u52a1\u72b6\u6001\uff0c\u914d\u7f6e\u5f00\u673a\u81ea\u542f\u3002<\/li>\n\n\n\n<li><strong>\u6570\u636e\u5e93\u64cd\u4f5c<\/strong>\uff1a\u6267\u884c SQL \u547d\u4ee4\uff08\u521b\u5efa\u5e93\/\u8868\u3001\u589e\u5220\u6539\u67e5\uff09\u3001\u7ba1\u7406\u7528\u6237\u6743\u9650\uff08 grant\/revoke\uff09\u3002<\/li>\n\n\n\n<li><strong>\u5907\u4efd\u4e0e\u6062\u590d<\/strong>\uff1a\u5b9a\u65f6\u751f\u6210\u6570\u636e\u5e93\u5907\u4efd\uff08mysqldump\uff09\u3001\u652f\u6301\u5168\u91cf\/\u589e\u91cf\u5907\u4efd\uff0c\u63d0\u4f9b\u5907\u4efd\u6587\u4ef6\u6062\u590d\u63a5\u53e3\u3002<\/li>\n\n\n\n<li><strong>\u6027\u80fd\u76d1\u63a7<\/strong>\uff1a\u67e5\u770b\u8fde\u63a5\u6570\u3001\u6162\u67e5\u8be2\u65e5\u5fd7\u3001\u7f13\u5b58\u547d\u4e2d\u7387\uff0c\u8c03\u6574 <code>my.cnf<\/code> \u4e2d\u7684\u6027\u80fd\u53c2\u6570\uff08\u5982 buffer_size\uff09\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e94\u3001\u64cd\u4f5c\u6d41\u7a0b\u8bbe\u8ba1<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u521d\u59cb\u5316<\/strong>\uff1a\u7528\u6237\u8f93\u5165\u670d\u52a1\u5668\u4fe1\u606f\uff08IP\u3001\u7aef\u53e3\u3001\u8ba4\u8bc1\u65b9\u5f0f\uff09\uff0c\u7cfb\u7edf\u5efa\u7acb\u8fde\u63a5\u5e76\u9a8c\u8bc1\u6743\u9650\u3002<\/li>\n\n\n\n<li><strong>\u529f\u80fd\u9009\u62e9<\/strong>\uff1a\u901a\u8fc7\u83dc\u5355\u6216\u547d\u4ee4\u53c2\u6570\u6307\u5b9a\u64cd\u4f5c\u7c7b\u578b\uff08\u5982\u6587\u4ef6\u7ba1\u7406\u3001\u9632\u706b\u5899\u914d\u7f6e\u7b49\uff09\u3002<\/li>\n\n\n\n<li><strong>\u6267\u884c\u64cd\u4f5c<\/strong>\uff1a\u7cfb\u7edf\u8c03\u7528\u5bf9\u5e94\u6a21\u5757\u5904\u7406\uff0c\u8fd4\u56de\u6267\u884c\u7ed3\u679c\uff08\u6210\u529f\/\u5931\u8d25\u539f\u56e0\uff09\u3002<\/li>\n\n\n\n<li><strong>\u65e5\u5fd7\u8bb0\u5f55<\/strong>\uff1a\u6240\u6709\u64cd\u4f5c\u81ea\u52a8\u8bb0\u5f55\uff08\u65f6\u95f4\u3001\u7528\u6237\u3001\u64cd\u4f5c\u5185\u5bb9\u3001\u7ed3\u679c\uff09\uff0c\u652f\u6301\u67e5\u8be2\u5ba1\u8ba1\u3002<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">\u516d\u3001\u6269\u5c55\u4e0e\u53ef\u9760\u6027\u8bbe\u8ba1<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u6279\u91cf\u7ba1\u7406<\/strong>\uff1a\u652f\u6301\u540c\u65f6\u8fde\u63a5\u591a\u53f0\u670d\u52a1\u5668\uff0c\u6267\u884c\u6279\u91cf\u64cd\u4f5c\uff08\u5982\u7edf\u4e00\u914d\u7f6e\u9632\u706b\u5899\u89c4\u5219\uff09\u3002<\/li>\n\n\n\n<li><strong>\u5bb9\u9519\u673a\u5236<\/strong>\uff1a\u64cd\u4f5c\u5931\u8d25\u65f6\u81ea\u52a8\u56de\u6eda\uff08\u5982\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u524d\u5907\u4efd\u539f\u6587\u4ef6\uff09\uff0c\u7f51\u7edc\u4e2d\u65ad\u540e\u81ea\u52a8\u91cd\u8bd5\u3002<\/li>\n\n\n\n<li><strong>\u6743\u9650\u63a7\u5236<\/strong>\uff1a\u533a\u5206\u7ba1\u7406\u5458\/\u666e\u901a\u7528\u6237\u6743\u9650\uff0c\u9650\u5236\u9ad8\u5371\u64cd\u4f5c\uff08\u5982\u5220\u9664\u7cfb\u7edf\u6587\u4ef6\u3001\u5173\u95ed\u9632\u706b\u5899\uff09\u3002<\/li>\n\n\n\n<li><strong>\u8de8\u53d1\u884c\u7248\u517c\u5bb9<\/strong>\uff1a\u9002\u914d Ubuntu\uff08Debian \u7cfb\uff09\u3001CentOS\uff08RHEL \u7cfb\uff09\u7b49\u4e3b\u6d41 Linux \u53d1\u884c\u7248\uff0c\u5904\u7406\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\u5dee\u5f02\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e03\u3001\u4ea4\u4ed8\u5f62\u5f0f<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6838\u5fc3\u7a0b\u5e8f\uff1aPython \u811a\u672c\u96c6\u5408\uff08\u6a21\u5757\u5316\u7ec4\u7ec7\uff09\u3002<\/li>\n\n\n\n<li>\u8fd0\u884c\u73af\u5883\uff1aPython 3.8+\uff0c\u4f9d\u8d56\u5e93\u5305\u62ec paramiko\uff08SSH\uff09\u3001python-dotenv\uff08\u914d\u7f6e\u7ba1\u7406\uff09\u7b49\u3002<\/li>\n\n\n\n<li>\u6587\u6863\uff1a\u64cd\u4f5c\u624b\u518c\uff08\u542b\u547d\u4ee4\u5217\u8868\uff09\u3001\u6a21\u5757\u63a5\u53e3\u8bf4\u660e\u3001\u6269\u5c55\u5f00\u53d1\u6307\u5357\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u8be5\u65b9\u6848\u901a\u8fc7\u6a21\u5757\u5316\u8bbe\u8ba1\u5b9e\u73b0 Linux \u670d\u52a1\u5668\u5168\u529f\u80fd\u7ba1\u7406\uff0c\u517c\u987e\u7075\u6d3b\u6027\u4e0e\u6613\u7528\u6027\uff0c\u53ef\u6ee1\u8db3\u4e2d\u5c0f\u578b\u670d\u52a1\u5668\u96c6\u7fa4\u7684\u65e5\u5e38\u8fd0\u7ef4\u9700\u6c42\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. System objectives<\/h2>\n\n\n\n<p>Build an integrated Linux server management system based on Python to achieve unified control of all server functions, covering core modules such as file operation, SSH configuration, network management, web services (Apache\/Nginx), firewall (UFW), and MySQL database, support local and remote server management, and provide intuitive operation interfaces (CLI or Web).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Core functional scope<\/h2>\n\n\n\n<p>Covers all scenarios of Linux server management, including:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>File management<\/strong>: create, delete, copy, move, modify permissions, compress\/decompress, edit content, analyze disk occupancy, etc.<\/li>\n\n\n\n<li><strong>SSH management<\/strong>: SSH service status monitoring, configuration modification (port, key authentication, login restrictions), user key management, connection log auditing, batch command execution, etc.<\/li>\n\n\n\n<li><strong>Network management<\/strong>: NIC configuration (IP, subnet mask, gateway), DNS settings, port listening detection, network traffic monitoring, routing table management, firewall rule association, etc.<\/li>\n\n\n\n<li><strong>Web Services Management<\/strong>:<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Apache: Service start, stop\/restart, virtual host configuration, module management, log analysis, and status monitoring.<\/li>\n\n\n\n<li>Nginx: Service control, profile validation, virtual host management, reverse proxy configuration, and performance parameter tuning.<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Firewall (UFW) management<\/strong>: firewall status switching, port release\/blocking, IP blacklist and whitelist settings, rule backup\/recovery, and status monitoring.<\/li>\n\n\n\n<li><strong>MySQL management<\/strong>: service start and stop, user permission management, database backup\/recovery, performance parameter configuration, connection status monitoring, and log analysis.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">3. System architecture design<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Overall architecture<\/h3>\n\n\n\n<p>It adopts a modular layered design and is divided into:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Basic layer<\/strong>: Responsible for connection management (local\/SSH sessions), permission verification, logging, and exception handling.<\/li>\n\n\n\n<li><strong>Functional module layer<\/strong>: Split independent modules (file, SSH, network, etc.) according to management objects, and low coupling between modules.<\/li>\n\n\n\n<li><strong>Interface layer<\/strong>: Provides CLI command-line interface (preferred) and reserves web interface extension capabilities.<\/li>\n\n\n\n<li><strong>Data layer<\/strong>: Stores server configuration information, operation logs, backup policies, etc. (supports local files or lightweight databases).<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. Module relationships<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>All functional modules rely on the connection management capabilities of the base layer to perform local\/remote operations through a unified interface.<\/li>\n\n\n\n<li>Function modules can be cross-called (for example, Web service management relies on firewall modules to configure port release).<\/li>\n\n\n\n<li>The interface layer aggregates all module functions to provide a unified user interaction portal.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">4. Detailed design of modules<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Base connection module<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Core competencies<\/strong>: Manage direct operation of local servers, SSH connections to remote servers (support password\/key authentication), connection pool maintenance, and session keeping.<\/li>\n\n\n\n<li><strong>Key features<\/strong>: automatic reconnection mechanism, operation timeout control, permission verification (ensure that the executing user has sufficient permissions).<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. File management module<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Local file operation<\/strong>: Based on the Python built-in file operation library, basic file\/directory management and permission control (mapping Linux chmod\/chown) are realized.<\/li>\n\n\n\n<li><strong>Remote file manipulation<\/strong>: Upload\/download files through the SFTP protocol, and execute remote commands to modify permissions, compress (tar\/zip), etc.<\/li>\n\n\n\n<li><strong>Advanced features<\/strong>: file difference comparison, batch file operation, large file breakpoint transfer, and disk space alarm.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3. SSH management module<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Service configuration<\/strong>: Read\/Modify, supports port change, disable password login, restrict root login, and other configuration items.<code>\/etc\/ssh\/sshd_config<\/code><\/li>\n\n\n\n<li><strong>Key management<\/strong>: Generate SSH key pairs, push public keys to remote servers (enable passwordless login), and manage files.<code>authorized_keys<\/code><\/li>\n\n\n\n<li><strong>Audit function<\/strong>: Parse SSH login logs () to count the number of logins and abnormal login alarms.<code>\/var\/log\/auth.log<\/code><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">4. Network management module<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>NIC configuration<\/strong>: Read\/modify network interface configuration files (such as or ) to support static IP and dynamic IP switching.<code>\/etc\/netplan\/<\/code><code>\/etc\/sysconfig\/network-scripts\/<\/code><\/li>\n\n\n\n<li><strong>Status monitoring<\/strong>: Execute \/ command to obtain the status of the network card, \/ check port occupancy, \/ detect network connectivity.<code>ifconfig<\/code><code>ip<\/code><code>netstat<\/code><code>ss<\/code><code>ping<\/code><code>traceroute<\/code><\/li>\n\n\n\n<li><strong>Traffic Analysis<\/strong>: Monitor real-time traffic through or parse to record traffic spikes.<code>iftop<\/code><code>\/proc\/net\/dev<\/code><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">5. Web Services Management Module (Apache\/Nginx)<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Service control<\/strong>: Supports configuration file syntax verification by managing service start-stop\/restart\/status query.<code>systemctl<\/code><\/li>\n\n\n\n<li><strong>Web hosting management<\/strong>: Create\/delete web hosting profiles, associate domain names and directories, and configure SSL certificate paths.<\/li>\n\n\n\n<li><strong>Performance monitoring<\/strong>: Obtain the current number of connections, request volume, and error rate (parse access logs), and support restart policies (such as automatic restart when the request volume is too high).<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">6. Firewall (UFW) management module<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Rule management<\/strong>: add\/remove port allow rules (such as allowing 80\/tcp), IP restrictions (such as prohibiting access to specific IPs), and adjust rule priority.<\/li>\n\n\n\n<li><strong>Status control<\/strong>: Enable\/disable firewall, view currently active rules, save\/restore rule configurations.<\/li>\n\n\n\n<li><strong>Log analysis<\/strong>: Parsing UFW logs, statistical interception records, and identifying abnormal access patterns.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">7. MySQL management module<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Service control<\/strong>: Manage MySQL service status and configure boot autostart.<code>systemctl<\/code><\/li>\n\n\n\n<li><strong>Database operations<\/strong>: Execute SQL commands (create libraries\/tables, add, delete, modify, and query) and manage user permissions (grant\/revoke).<\/li>\n\n\n\n<li><strong>Backup and recovery<\/strong>: Generate database backups (mysqldump) regularly, support full\/incremental backups, and provide backup file recovery interfaces.<\/li>\n\n\n\n<li><strong>Performance monitoring<\/strong>: View the number of connections, slow query logs, cache hit rate, and adjust performance parameters (such as buffer_size).<code>my.cnf<\/code><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">5. Operation process design<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Initialization<\/strong>: The user enters the server information (IP, port, and authentication method), and the system establishes a connection and verifies the permissions.<\/li>\n\n\n\n<li><strong>Function Selection<\/strong>: Specify the type of operation (such as file management, firewall configuration, etc.) through menus or command parameters.<\/li>\n\n\n\n<li><strong>Execution<\/strong>: The system calls the corresponding module to process and returns the execution result (success\/failure reason).<\/li>\n\n\n\n<li><strong>Logging<\/strong>: All operations (time, user, operation content, and result) are automatically recorded, and query auditing is supported.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">6. Expansion and reliability design<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Batch management<\/strong>: Supports connecting multiple servers at the same time to perform batch operations (such as uniformly configuring firewall rules).<\/li>\n\n\n\n<li><strong>Fault tolerance mechanism<\/strong>: Automatically rolls back when the operation fails (for example, backing up the original file before modifying the configuration file), and automatically retries after network interruption.<\/li>\n\n\n\n<li><strong>Permission control<\/strong>: Distinguish between administrator and ordinary user permissions and restrict high-risk operations (such as deleting system files and turning off firewalls).<\/li>\n\n\n\n<li><strong>Cross-distribution compatibility<\/strong>: Compatible with mainstream Linux distributions such as Ubuntu (Debian series) and CentOS (RHEL series) to handle configuration file path differences.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">7. Form of delivery<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Core program: Python script collection (modular organization).<\/li>\n\n\n\n<li>Running environment: Python 3.8+, dependency libraries include paramiko (SSH), python-dotenv (configuration management), etc.<\/li>\n\n\n\n<li>Documentation: Operation manual (including command list), module interface description, extension development guide.<\/li>\n<\/ul>\n\n\n\n<p>This solution realizes full-function management of Linux servers through modular design, taking into account flexibility and ease of use, and can meet the daily operation and maintenance needs of small and medium-sized server clusters.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b98\u65b9\u7f51 linux.silubaba.com.cn \u4e00\u3001\u7cfb\u7edf\u76ee\u6807 \u6784\u5efa\u4e00\u5957\u57fa\u4e8e Python \u7684\u96c6\u6210\u5316 Linux \u670d\u52a1\u5668\u7ba1\u7406\u7cfb\u7edf\uff0c\u5b9e\u73b0\u5bf9\u670d\u52a1\u5668\u5168\u529f\u80fd\u7684\u7edf\u4e00\u7ba1\u63a7\uff0c\u6db5\u76d6\u6587\u4ef6\u64cd\u4f5c\u3001SSH \u914d\u7f6e\u3001\u7f51\u7edc\u7ba1\u7406\u3001Web \u670d\u52a1\uff08Apache\/Nginx\uff09\u3001\u9632\u706b\u5899\uff08UFW\uff09\u53ca MySQL \u6570\u636e\u5e93\u7b49\u6838\u5fc3\u6a21\u5757\uff0c\u652f\u6301\u672c\u5730\u53ca\u8fdc\u7a0b\u670d\u52a1\u5668\u7ba1\u7406\uff0c\u63d0\u4f9b\u76f4\u89c2\u7684\u64cd\u4f5c\u63a5\u53e3\uff08CLI \u6216 Web\uff09\u3002 \u4e8c\u3001\u6838\u5fc3\u529f\u80fd\u8303\u56f4 \u8986\u76d6 Linux \u670d\u52a1\u5668\u7ba1\u7406\u5168\u573a\u666f\uff0c\u5177\u4f53\u5305\u62ec\uff1a \u4e09\u3001\u7cfb\u7edf\u67b6\u6784\u8bbe\u8ba1 1. \u6574\u4f53\u67b6\u6784 \u91c7\u7528\u6a21\u5757\u5316\u5206\u5c42\u8bbe\u8ba1\uff0c\u5206\u4e3a\uff1a 2. \u6a21\u5757\u5173\u7cfb \u56db\u3001\u6a21\u5757\u8be6\u7ec6\u8bbe\u8ba1 1. \u57fa\u7840\u8fde\u63a5\u6a21\u5757 2. \u6587\u4ef6\u7ba1\u7406\u6a21\u5757 3. SSH \u7ba1\u7406\u6a21\u5757 4. \u7f51\u7edc\u7ba1\u7406\u6a21\u5757 5. Web \u670d\u52a1\u7ba1\u7406\u6a21\u5757\uff08Apache\/Nginx\uff09 6. \u9632\u706b\u5899\uff08UFW\uff09\u7ba1\u7406\u6a21\u5757 7. MySQL \u7ba1\u7406\u6a21\u5757 \u4e94\u3001\u64cd\u4f5c\u6d41\u7a0b\u8bbe\u8ba1 \u516d\u3001\u6269\u5c55\u4e0e\u53ef\u9760\u6027\u8bbe\u8ba1 \u4e03\u3001\u4ea4\u4ed8\u5f62\u5f0f \u8be5\u65b9\u6848\u901a\u8fc7\u6a21\u5757\u5316\u8bbe\u8ba1\u5b9e\u73b0 Linux \u670d\u52a1\u5668\u5168\u529f\u80fd\u7ba1\u7406\uff0c\u517c\u987e\u7075\u6d3b\u6027\u4e0e\u6613\u7528\u6027\uff0c\u53ef\u6ee1\u8db3\u4e2d\u5c0f\u578b\u670d\u52a1\u5668\u96c6\u7fa4\u7684\u65e5\u5e38\u8fd0\u7ef4\u9700\u6c42\u3002 1. System objectives Build an integrated Linux [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4636,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[8],"tags":[],"class_list":["post-4633","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-new-production"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/silubaba.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/4633","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/silubaba.com.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/silubaba.com.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/silubaba.com.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/silubaba.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4633"}],"version-history":[{"count":2,"href":"https:\/\/silubaba.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/4633\/revisions"}],"predecessor-version":[{"id":4638,"href":"https:\/\/silubaba.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/4633\/revisions\/4638"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/silubaba.com.cn\/index.php?rest_route=\/wp\/v2\/media\/4636"}],"wp:attachment":[{"href":"https:\/\/silubaba.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4633"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/silubaba.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4633"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/silubaba.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}