{"id":331,"date":"2025-04-07T11:56:09","date_gmt":"2025-04-07T03:56:09","guid":{"rendered":"https:\/\/00af.com\/?p=331"},"modified":"2025-11-18T02:32:22","modified_gmt":"2025-11-17T18:32:22","slug":"debian-ubuntu-centos%e6%9c%8d%e5%8a%a1%e5%99%a8linux%e5%b8%b8%e7%94%a8%e9%85%8d%e7%bd%ae%e5%91%bd%e4%bb%a4%e5%8f%8a%e7%ae%a1%e7%90%86%e8%84%9a%e6%9c%ac%e6%94%b6%e8%97%8f%e5%88%86%e4%ba%ab","status":"publish","type":"post","link":"https:\/\/00af.com\/?p=331","title":{"rendered":"Debian\/ubuntu\/centos\u670d\u52a1\u5668Linux\u5e38\u7528\u914d\u7f6e\u547d\u4ee4\u53ca\u7ba1\u7406\u811a\u672cOpenWRT"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">\u57fa\u4e8eDebian\/Ubuntu\u7cfb\u7edf<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>ub24\u4f7f\u7528netplan\u529f\u80fd\u8bbe\u7f6e\u52a8\u6001IP\nvim \/etc\/netplan\/*.yaml #\u5f00\u542fDHCP\u83b7\u53d6IP\n#\u4fee\u6539\u5bf9\u5e94\u7f51\u5361\u540d\u79f0 ens3 eth0\nsudo netplan apply \u5e94\u7528\u914d\u7f6e\u6587\u4ef6\nreboot\/init 0 #\u91cd\u542f\u4e0e\u5173\u673a\ndpkg -l #\u67e5\u770b\u6240\u6709\u8f6f\u4ef6\ndpkg -l | grep vim #\u8fc7\u6ee4vim\napt list --installed #\u67e5\u770b\u901a\u8fc7install\u547d\u4ee4\u5b89\u88c5\u7684\u8f6f\u4ef6\napt list --installed | grep nginx #\u67e5\u770b\u4e0enginx\u76f8\u5173\nsudo apt remove \u8f6f\u4ef6\u5305 #\u5378\u8f7d\u5e76\u4fdd\u7559\u914d\u7f6e\u6570\u636e\nsudo apt purge \u8f6f\u4ef6\u5305 #\u5378\u8f7d\u4e0d\u4fdd\u7559\u914d\u7f6e\u6570\u636e\nsudo apt autoremove \u8f6f\u4ef6\u5305 #\u5378\u8f7d\u5e76\u5220\u9664\u6570\u636e\u4e0e\u76f8\u5173\u4f9d\u8d56\n\n\/etc\/network\/interfaces #\u6dfb\u52a0ipv6\niface eth0 inet6 static\n    address 2001:db8::1 #ipv6\u5730\u5740\n    netmask 64 \u4f4d\u7801\n    gateway 2001:db8::fffe #\u7f51\u5173\u5982\u679c\u6709\n\u65b0\u7248netplan\u7ba1\u7406\u547d\u4ee4\n\n\u5f00\u673a\u81ea\u542f\u811a\u672cetc\/init.d\/\nupdate-rc.d xxx.sh defaults 90 #\u589e\u52a0\u542f\u52a8\u811a\u672c\nupdate-rc.d -f xxxx.sh remove #\u5220\u9664\u542f\u52a8\u811a\u672c\n#\u521b\u5efa\u7684sh\u811a\u672c\u6587\u4ef6\u9700\u8981\u6709\u8fd0\u884c\u6743\u9650\n\n\u63a8\u8350\u4f7f\u7528\/etc\/systemd\/system\u670d\u52a1\u542f\u52a8\n&#91;Unit]\nDescription=s-ui Service\nAfter=network.target\nWants=network.target\n\n&#91;Service]\nType=simple\nWorkingDirectory=\/usr\/local\/s-ui\/ \u8fd0\u884c\u76ee\u5f55\nExecStart=\/usr\/local\/s-ui\/sui \u8fd0\u884c\u7a0b\u5e8f\nRestart=on-failure\nRestartSec=10s\n\n&#91;Install]\nWantedBy=multi-user.target\n\n#\u5b9a\u65f6\u4efb\u52a1\u5f00\u673a\u81ea\u542f\ncrontab -e\n@reboot sleep 10 &amp;&amp; \/root\/e -c e.toml\n\u5f00\u673a\u5ef6\u65f610\u79d2\u7acb\u5373\u542f\u52a8\u6307\u5b9a\u7a0b\u5e8f\u53c2\u6570\n#\u5b98\u65b9WRT\u6d4b\u8bd5\u5931\u8d25\n<\/code><\/pre>\n\n\n\n<p>\u6587\u4ef6\u64cd\u4f5c\u7c7b\u547d\u4ee4<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mv old_filename new_filename #\u66f4\u540d\u6216\u79fb\u52a8\nrename #\u66f4\u540d\u6587\u4ef6\u6216\u6587\u4ef6\u5939\nrename 's\/old_filename\/new_filename\/' file\ncp source_dir\/*.txt destination_dir\/ #\u590d\u5236\n\u8fd0\u884c\u65f6.\/abc.sh\u8868\u793a\u5f53\u524d\u6240\u5728\u76ee\u5f55\u4e0b\/root\/s\/abc.sh\u7edd\u5bf9\u5168\u8def\u5f84<\/code><\/pre>\n\n\n\n<p>sh\u811a\u672c\u7c7b\u547d\u4ee4<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>WRT\u5982\u679c\u662fbas\u7c7b\u578b\u7684\nsh\u6587\u4ef6\u5f00\u5173\u4e00\u884c\u884c\u5fc5\u987b\u662f#!\/bin\/sh\n\u5426\u5219\u4f1a\u63d0\u793a-ash: \/root\/g.sh: not found\n\u5982\u679c\u662fbash\u7c7b\u578b\u53ef\u5c1d\u8bd5#!\/bin\/bash<\/code><\/pre>\n\n\n\n<p>OpenWRT\u5f00\u673a\u81ea\u542f\/\u8ba1\u5212\u4efb\u52a1\/init.d\u540e\u53f0\u670d\u52a1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> \/etc\/rc.local #\u672c\u5730\u5f00\u673a\u542f\u52a8\n\u53ea\u53ef\u7b2c\u4e00\u884c\u53ef\u4ee5\u6267\u884c\uff0c\u53ef\u6267\u884csh\u6587\u4ef6\u591a\u4e2a\u4efb\u52a1\nsh\u6587\u4ef6\u591a\u4e2a\u4efb\u52a1\u811a\u672c\u793a\u4f8b\n#!\/bin\/sh \/etc\/rc.common\n\/root\/e -w 00af &amp;\n\/root\/u\/uif &amp;\ncd \/root\n.\/hysteria &amp;\nwait\n\u5982\u679c\u6bcf\u884c\u76f4\u63a5\u5199\u7a0b\u5e8f\u8def\u5f84\u4e0d\u80fd\u6267\u884c\u53ef\u5148\u52a0\u4e00\u884c\u8fdb\u5165\u76ee\u5f55\u540e\u4ee5\u6240\u5728\u76ee\u5f55\u8fd0\u884c\n#!\/bin\/sh \/etc\/rc.common \u5b98\u65b9\u4e0eiKWRT\n#!\/bin\/bash \/etc\/rc.common Kwrt\nDocker\u6216\u6709\u4e9b\u670d\u52a1\u8bbe\u7f6e\u4e86\u5f00\u673a\u81ea\u542f\u4f46\u6ca1\u6709\u542f\u52a8\uff0c\u9700\u8981\u5230\u670d\u52a1\u91cc\u624b\u52a8\u5f00\u542f\uff0c\u6216\u52a0\u5927\u670d\u52a1\u7684\u5f00\u673a\u4f18\u5148\u987a\u5e8f\uff0c\u9ed8\u8ba499\u53ef\u6539\u4e3a10\u5de6\u53f3\n\u63a8\u8350\u4f18\u5148\u4f7f\u7528init.d\u670d\u52a1\u65b9\u5f0f\u81ea\u542f\u52a8\uff0c\u4f46\u8fd9\u79cd\u914d\u7f6e\u6210\u529f\u7387\u4f4e\uff0csh\u6216\u8ba1\u5212\u4efb\u52a1\u7684\u65b9\u5f0f\u66f4\u7b80\u5355\u3002\n\u589e\u52a0\u4e00\u4e2a&amp;\u53f7\u8868\u793a\u957f\u671f\u8fd0\u884c<\/code><\/pre>\n\n\n\n<p>IP\u5730\u5740\u914d\u7f6e\u76f8\u5173<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">dhclient eth0 #\u4e34\u65f6\u8bbe\u7f6eeth0\u4e3a\u52a8\u6001\u83b7\u53d6IP<br><br>sudo nmcli con mod eth0 ipv4.addresses 192.168.1.100\/24<br>sudo nmcli con mod eth0 ipv4.gateway 192.168.1.1<br>sudo nmcli con mod eth0 ipv4.method manual<br>sudo nmcli con up eth0<br><br>sudo ip addr add 192.168.1.100\/24 dev eth0 #\u4e34\u65f6\u8bbe\u7f6e<br><br># \/etc\/network\/interfaces #\u914d\u7f6eIP\u6587\u4ef6\u4e3a\u9759\u6001<br>auto eth0<br>iface eth0 inet static<br>    address 192.168.1.100<br>    netmask 255.255.255.0<br>    gateway 192.168.1.1<br>    dns-nameservers 8.8.8.8 8.8.4.4<br>systemctl restart networking # reboot<br><br>nm-connection-editor #\u56fe\u5f62\u914d\u7f6e\u5de5\u5177<\/pre>\n\n\n\n<p>netplan\u914d\u7f6eIP\u547d\u4ee4\u811a\u672c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n# \u8bbe\u7f6eNetplan\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\u548c\u5185\u5bb9\nCONFIG_FILE=\"\/etc\/netplan\/01-netcfg.yaml\"\nCONFIG_CONTENT=\"network:\n  version: 2\n  ethernets:\n    eth0:\n      dhcp4: no\n      addresses: &#91;192.168.1.100\/24]\n      gateway4: 192.168.1.1\n      nameservers:\n        addresses: &#91;8.8.8.8, 8.8.4.4]\"\n\n# \u521b\u5efa\u6216\u66f4\u65b0Netplan\u914d\u7f6e\u6587\u4ef6\necho \"$CONFIG_CONTENT\" | sudo tee \"$CONFIG_FILE\" > \/dev\/null\n\n# \u5e94\u7528Netplan\u914d\u7f6e\nsudo netplan apply<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u57fa\u4e8eDebian\/Ubuntu\u7cfb\u7edf \u6587\u4ef6\u64cd\u4f5c\u7c7b\u547d\u4ee4 sh\u811a\u672c\u7c7b\u547d\u4ee4 OpenWRT\u5f00\u673a\u81ea\u542f\/\u8ba1\u5212\u4efb\u52a1\/init [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-331","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/00af.com\/index.php?rest_route=\/wp\/v2\/posts\/331","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/00af.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/00af.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/00af.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/00af.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=331"}],"version-history":[{"count":3,"href":"https:\/\/00af.com\/index.php?rest_route=\/wp\/v2\/posts\/331\/revisions"}],"predecessor-version":[{"id":974,"href":"https:\/\/00af.com\/index.php?rest_route=\/wp\/v2\/posts\/331\/revisions\/974"}],"wp:attachment":[{"href":"https:\/\/00af.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/00af.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/00af.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}