{"id":388,"date":"2022-02-07T14:20:17","date_gmt":"2022-02-07T06:20:17","guid":{"rendered":"https:\/\/830519.xyz\/?p=388"},"modified":"2023-03-22T15:58:51","modified_gmt":"2023-03-22T07:58:51","slug":"debian","status":"publish","type":"post","link":"https:\/\/830519.xyz\/?p=388","title":{"rendered":"Debian"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code><a rel=\"noreferrer noopener\" href=\"https:\/\/www.debian.org\/\" target=\"_blank\">https:\/\/www.debian.org\/<\/a>\ncat \/etc\/os-release\n\nnano \/etc\/apt\/sources.list\ndeb https:\/\/mirrors.aliyun.com\/debian\/ bullseye main non-free contrib\ndeb-src https:\/\/mirrors.aliyun.com\/debian\/ bullseye main non-free contrib\ndeb https:\/\/mirrors.aliyun.com\/debian-security\/ bullseye-security main\ndeb-src https:\/\/mirrors.aliyun.com\/debian-security\/ bullseye-security main\ndeb https:\/\/mirrors.aliyun.com\/debian\/ bullseye-updates main non-free contrib\ndeb-src https:\/\/mirrors.aliyun.com\/debian\/ bullseye-updates main non-free contrib\ndeb https:\/\/mirrors.aliyun.com\/debian\/ bullseye-backports main non-free contrib\ndeb-src https:\/\/mirrors.aliyun.com\/debian\/ bullseye-backports main non-free contrib<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8bbe\u7f6eRoot\u767b\u9646<\/strong>\nnano \/etc\/ssh\/sshd_config\n# \u5728 sshd_config \u6587\u4ef6\u91cc\u7684 \u201cAuthentication\u201d \u90e8\u5206\u52a0\u4e0a\u4ee5\u4e0b\u5185\u5bb9\nPermitRootLogin yes\n# \u5b8c\u6210\u4ee5\u540e\u9000\u51fa vim \u5e76\u4fdd\u5b58\npasswd root # \u76f4\u63a5\u4fee\u6539 Root \u7528\u6237\u7684\u5bc6\u7801\nservice sshd restart # \u91cd\u542f ssh \u670d\u52a1\u4ee5\u5e94\u7528\u66f4\u6539<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u914d\u7f6e sudo user<\/strong>\n$ su - root\n# apt install sudo -y\n# usermod -aG sudo gxx\n# su \u2013 pkumar\n$ sudo apt update\n\n<strong>debian\u4e0b\u521b\u5efa\u65b0\u7528\u6237<\/strong>\n1.\u5728root\u7528\u6237\u4e0b\ngroupadd gxx\nuseradd -m gxx -g gxx -s \/bin\/bash -d \/home\/gxx\npasswd gxx\n\n2.\u4f7f\u7528sudo\nsudo useradd -m gxx -g sudo -s \/bin\/bash -d \/home\/gxx\nsudo passwd gxx\n\n\u8ba9\u6b64\u7528\u6237\u6709root\u6743\u9650\napt install sudo -y\nnano \/etc\/sudoers\n# User privilege specification\nroot ALL=(ALL) ALL\ngxx ALL=(ALL) ALL\n\nuseradd\u547d\u4ee4\u7684\u53c2\u6570\uff1a\n-c&lt;\u5907\u6ce8&gt;\uff1a\u52a0\u4e0a\u5907\u6ce8\u6587\u5b57\u3002\u5907\u6ce8\u6587\u5b57\u4f1a\u4fdd\u5b58\u5728passwd\u7684\u5907\u6ce8\u680f\u4f4d\u4e2d\uff1b\n-d&lt;\u767b\u5165\u76ee\u5f55&gt;\uff1a\u6307\u5b9a\u7528\u6237\u767b\u5165\u65f6\u7684\u542f\u59cb\u76ee\u5f55\uff1b -D\uff1a\u53d8\u66f4\u9884\u8bbe\u503c\uff1b\n-e&lt;\u6709\u6548\u671f\u9650&gt;\uff1a\u6307\u5b9a\u5e10\u53f7\u7684\u6709\u6548\u671f\u9650\uff1b\n-f&lt;\u7f13\u51b2\u5929\u6570&gt;\uff1a\u6307\u5b9a\u5728\u5bc6\u7801\u8fc7\u671f\u540e\u591a\u5c11\u5929\u5373\u5173\u95ed\u8be5\u5e10\u53f7\uff1b\n-g&lt;\u7fa4\u7ec4&gt;\uff1a\u6307\u5b9a\u7528\u6237\u6240\u5c5e\u7684\u7fa4\u7ec4\uff1b\n-G&lt;\u7fa4\u7ec4&gt;\uff1a\u6307\u5b9a\u7528\u6237\u6240\u5c5e\u7684\u9644\u52a0\u7fa4\u7ec4\uff1b\n-m\uff1a\u81ea\u52a8\u5efa\u7acb\u7528\u6237\u7684\u767b\u5165\u76ee\u5f55\uff1b\n-M\uff1a\u4e0d\u8981\u81ea\u52a8\u5efa\u7acb\u7528\u6237\u7684\u767b\u5165\u76ee\u5f55\uff1b\n-n\uff1a\u53d6\u6d88\u5efa\u7acb\u4ee5\u7528\u6237\u540d\u79f0\u4e3a\u540d\u7684\u7fa4\u7ec4\uff1b\n-r\uff1a\u5efa\u7acb\u7cfb\u7edf\u5e10\u53f7\uff1b\n-s\uff1a\u6307\u5b9a\u7528\u6237\u767b\u5165\u540e\u6240\u4f7f\u7528\u7684shell\uff1b\n-u\uff1a\u6307\u5b9a\u7528\u6237id\u3002<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u5f00\u542fBBR<\/strong>\necho \"net.core.default_qdisc=fq\" &gt;&gt; \/etc\/sysctl.conf\necho \"net.ipv4.tcp_congestion_control=bbr\" &gt;&gt; \/etc\/sysctl.conf\nsysctl -p\nsysctl net.ipv4.tcp_available_congestion_control\nlsmod | grep bbr<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u66f4\u6362cloud\u5185\u6838<\/strong>\n<a rel=\"noreferrer noopener\" href=\"https:\/\/packages.debian.org\/stable\/kernel\/linux-image-cloud-amd64\" target=\"_blank\">https:\/\/packages.debian.org\/stable\/kernel\/linux-image-cloud-amd64<\/a>\napt update &amp;&amp; apt install linux-image-cloud-amd64<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>Debian10 Vim\/vi \u65e0\u6cd5\u4f7f\u7528\u9f20\u6807\u53f3\u952e\u7c98\u8d34<\/strong>\nvim \/usr\/share\/vim\/vim82\/defaults.vim\n\u627e\u5230set mouse=a\u4fee\u6539\u4e3aset mouse=r\n--------------------------------------------\nvim \/usr\/share\/vim\/vim81\/defaults.vim\n\u627e\u5230\uff1a\nif has('mouse')\n  set mouse=a\nendif\n\nset mouse=a\n\u6539\u4e3a\uff1a\nset mouse-=a<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>Debian10 \u5f00\u673a\u81ea\u542f\u52a8\u811a\u672c<\/strong>\n#\u4ee5\u524d\uff0c\u5982\u679c\u60f3\u8981\u5efa\u7acb\u670d\u52a1\u7cfb\u7edf\uff0c\u5c31\u5f97\u8981\u5230 \/etc\/init.d\/\u4e0b\u9762\u53bb\u5efa\u7acb\u76f8\u5bf9\u5e94\u5f97bash\u811a\u672c\u6765\u5b8c\u6210\u3002\u73b0\u5728\u5728systemd\u73af\u5883\u4e0b\u9762\uff0c\u60f3\u8981\u8bbe\u7f6e\u76f8\u5173\u7684\u670d\u52a1\u542f\u52a8\u73af\u5883\uff0c\u90a3\u4e48\u8be5\u5982\u4f55\u5904\u7406\u5462\uff1f \u7cfb\u7edf\u670d\u52a1\u7684\u7ba1\u7406\u662f\u901a\u8fc7systemd\u6765\u5b8c\u6210\u7684\uff0c\u800csystemd\u7684\u914d\u7f6e\u6587\u4ef6\u5927\u90e8\u5206\u653e\u7f6e\u4e8e\/lib\/systemd\/system\u76ee\u5f55\u4e2d\uff0c\u4f46\u662f\u5b98\u65b9\u6587\u6863\u6307\u51fa\uff0c\u8be5\u76ee\u5f55\u7684\u6587\u4ef6\u4e3b\u8981\u662f\u539f\u672c\u8f6f\u4ef6\u6240\u63d0\u4f9b\u7684\u8bbe\u7f6e\uff0c\u5efa\u8bae\u4e0d\u8981\u4fee\u6539\uff0c\u800c\u8981\u4fee\u6539\u7684\u4f4d\u7f6e\u5e94\u8be5\u653e\u7f6e\u4e8e\/etc\/systemd\/system\/\u76ee\u5f55\u4e2d\u3002\n\nls \/lib\/systemd\/system\ncat \/lib\/systemd\/system\/rc.local.service\nvim \/etc\/rc.local\n\n\u6dfb\u52a0\u81ea\u542f\u811a\u672c\uff1a\n#!\/bin\/sh -e\n#\n# rc.local\n#\n# This script is executed at the end of each multiuser runlevel.\n# Make sure that the script will \"exit 0\" on success or any other\n# value on error.\n#\n# In order to enable or disable this script just change the execution\n# bits.\n#\n# By default this script does nothing.\n\/\/ \u5728 exit 0 \u4e4b\u524d\u6dfb\u52a0\u542f\u52a8\u811a\u672c\nexit 0\n\nchmod +x \/etc\/rc.local\n\n#\u5728 \/etc\/systemd\/system \u76ee\u5f55\u4e0b\u521b\u5efa\u8f6f\u94fe\u63a5\nln -s \/lib\/systemd\/system\/rc.local.service \/etc\/systemd\/system\/<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>Debian\u4e2d\u5982\u4f55\u914d\u7f6eipv6<\/strong>\n\n\u7cfb\u7edf\u662f\u5426\u6709\u52a0\u8f7dipv6\u5185\u6838\nlsmod | grep ipv6\n\u5982\u679c\u6709\u7c7b\u4f3c\u7684\u8f93\u51fa\uff0c\u5219\u8868\u793a\u5df2\u7ecf\u52a0\u8f7d\n\nnf_log_ipv6            16384  5\nnf_reject_ipv6         20480  1 ip6t_REJECT\nnf_log_common          16384  2 nf_log_ipv4,nf_log_ipv6\nnf_defrag_ipv6         24576  1 nf_conntrack\n\n\u5426\u542f\u7528ipv6\ncat \/proc\/sys\/net\/ipv6\/conf\/all\/disable_ipv6\n\u5982\u679c\u8f93\u51fa 0 \uff0c\u5219\u8868\u793a\u542f\u7528\u4e86\uff0c\u5982\u679c\u8f93\u5165 1 \u5219\u8868\u793a\u6ca1\u6709\u542f\u7528\u3002\u5f88\u670b\u53cb\u914d\u7f6e\u4e0d\u6210\u529f\u95ee\u9898\u5c31\u51fa\u5728\u8fd9\u91cc\u3002\n\u600e\u4e48\u89e3\u51b3\uff1f\u5bf9\u4e8eDebian 11\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6 \/etc\/sysctl.conf\nvi \/etc\/sysctl.conf\n\u627e\u5230 net.ipv6.conf.all.disable_ipv6 = 1 \uff0c\u5c061\u6539\u4e3a0\u5373\u53ef\u3002\n\n\u6700\u540e\u522b\u5fd8\u8bb0 \u91cd\u542f\u7f51\u7edc\u6216\u8005\u91cd\u542f\u7cfb\u7edf\u3002\n\n<strong>VPS\u5e38\u7528\u914d\u7f6e<\/strong>\nnano \/etc\/network\/interfaces\n\n# This file describes the network interfaces available on your system\n# and how to activate them. For more information, see interfaces(5).\n\nsource \/etc\/network\/interfaces.d\/*\n\n# The loopback network interface\nauto lo\niface lo inet loopback\n\n# The primary network interface\nallow-hotplug ens18\niface ens18 inet static\n        address 104.245.12.20\/24\n        gateway 104.245.12.1\n        # dns-* options are implemented by the resolvconf package, if installed\n        dns-nameservers 8.8.8.8\n        dns-search vps.hosting\niface ens18 inet6 static\n        address 2604:a840:2::229\/48\n        gateway 2604:a840:2::1\n        dns-nameservers 2001:4860:4860::8844 2001:4860:4860::8888\n------------------------------------------------\n# This file describes the network interfaces available on your system\n# and how to activate them. For more information, see interfaces(5).\n\nsource \/etc\/network\/interfaces.d\/*\n\n# The loopback network interface\nauto lo\niface lo inet loopback\n\n# The primary network interface\nallow-hotplug ens3\niface ens3 inet static\n        address 108.166.219.112\/26\n        gateway 108.166.219.65\n        # dns-* options are implemented by the resolvconf package, if installed\n        dns-nameservers 8.8.8.8\n        dns-search com\n#auto ens4\n#iface ens4 inet6 static\n#        address 2607:f130:0:f0::115\/64\n#        netmask 64\n#        gateway 2607:f130:0:f0::1\n#        up ip addr add 2607:f130:0:f0::116\/64 dev ens4\n#        up ip addr add 2607:f130:0:f0::117\/64 dev ens4\n---------------------------------------------------------------\nauto lo\n  iface lo inet loopback\n\nauto ens3\n  iface ens3 inet static\n   address xxx(ipv4\u5730\u5740)\n   gateway xxx(ipv4\u7f51\u5173)\n   netmask 255.255.255.0\n   dns-nameservers 8.8.8.8 8.8.4.4\n   up ip addr add xxxx(ipv6\u5730\u5740)\/40 dev ens3\n   up ip -6 route add xxx(ipv6\u7f51\u5173) dev ens3\n   up ip -6 route add default via xxx(ipv6\u7f51\u5173)\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u4fee\u6539tmpfs\u5927\u5c0f<\/strong>\ndf -h\nmkdir \/root\/qbittorrent2\/downloads\/ram\nmount -t tmpfs -o size=2048m  tmpfs \/root\/qbittorrent2\/downloads\/ram\nvi \/etc\/fstab\ntmpfs                   \/dev\/shm                tmpfs   defaults,size=20G   0 0\ntmpfs                   \/root\/qbittorrent2\/downloads\/RAM                tmpfs   defaults,size=2G   0 0\nswapoff -a<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u5c06 Debian 11 \u5f15\u5bfc\u5230\u6551\u63f4 \/ \u7d27\u6025\u6a21\u5f0f<\/strong>\n\u901a\u5e38 Linux \u7cfb\u7edf\u542f\u52a8\u5230\u6551\u63f4\u6a21\u5f0f\uff0c\u4ee5\u6062\u590d\u5fd8\u8bb0\u7684\u6839\u5bc6\u7801\u548c\u4fee\u590d\u635f\u574f\u7684\u6587\u4ef6\u7cfb\u7edf\u3002\u6551\u63f4\u6a21\u5f0f\u52a0\u8f7d\u4e00\u4e2a\u6700\u5c0f\u7684\u73af\u5883\uff0c\u5176\u4e2d\u53ea\u6709\u53ea\u8bfb\u7684\u6839\u6587\u4ef6\u7cfb\u7edf\uff0c\u800c\u7d27\u6025\u6a21\u5f0f\u4e0d\u6302\u8f7d\u6839\u6587\u4ef6\u7cfb\u7edf\u3002\n\n<strong>\u6551\u63f4\u6a21\u5f0f<\/strong>\n\u91cd\u542f Debian 11 \u7cfb\u7edf\uff0c\u7136\u540e\u9009\u62e9\u201c Debian GNU\/Linux\u201d\u3002\n\u6309 e \u952e\uff0c\u7136\u540e\u8f6c\u5230\u4ee5 linux \u5f00\u5934\u7684\u884c\u5c3e\uff0c\u5e76\u9644\u52a0 init=\/bin\/bash\n\u6309 Ctrl-x \u6216 F10 \u542f\u52a8\uff0c\n\u4ee5\u8bfb\u5199\u6a21\u5f0f\u6302\u8f7d\u6839\u6587\u4ef6\u7cfb\u7edf\uff0c\u8fd0\u884c\n# mount -o remount,rw \/\n\u4e00\u65e6\u6587\u4ef6\u7cfb\u7edf\u4ee5 rw \u6a21\u5f0f\u6302\u8f7d\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u6267\u884c\u7ba1\u7406\u547d\u4ee4\uff0c\u4f8b\u5982\u91cd\u7f6e root \u5bc6\u7801\n\u5b8c\u6210\u6240\u6709\u6545\u969c\u6392\u9664\u540e\uff0c\u901a\u8fc7\u6309 Ctrl + Alt + Del \u91cd\u65b0\u542f\u52a8\u7cfb\u7edf\n\n<strong>\u7d27\u6025\u6a21\u5f0f<\/strong>\n\u6309 e \u952e\u5e76\u8f6c\u5230\u4ee5 linux \u5f00\u5934\u7684\u884c\u5c3e\uff0c\u5e76\u9644\u52a0 system.unit=emergency.target\n\u6309 Ctrl-x \u6216 F10 \u542f\u52a8\u5230\u7d27\u6025\u6a21\u5f0f\n\u6ce8\u610f: \u5982\u679c\u5df2\u5728\u7cfb\u7edf\u4e2d\u8bbe\u7f6e\u4e86 root \u5bc6\u7801\uff0c\u5219\u5fc5\u987b\u8f93\u5165 root \u5bc6\u7801\u624d\u80fd\u5728\u7d27\u6025\u6a21\u5f0f\u4e0b\u5de5\u4f5c\u3002\n\u8f93\u5165 root \u7528\u6237\u5bc6\u7801\u4ee5\u83b7\u53d6 shell\uff0c\u4ee5\u8bfb\u5199\u6a21\u5f0f\u6302\u8f7d\u6839\u6587\u4ef6\u7cfb\u7edf\n# mount -o remount,rw \/\n\u5b8c\u6210\u6240\u6709\u6545\u969c\u6392\u9664\u540e\uff0c\u6267\u884c systemctl reboot \u91cd\u65b0\u542f\u52a8\u7cfb\u7edf\n# systemctl reboot<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-388","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/830519.xyz\/index.php?rest_route=\/wp\/v2\/posts\/388","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/830519.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/830519.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/830519.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/830519.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=388"}],"version-history":[{"count":12,"href":"https:\/\/830519.xyz\/index.php?rest_route=\/wp\/v2\/posts\/388\/revisions"}],"predecessor-version":[{"id":729,"href":"https:\/\/830519.xyz\/index.php?rest_route=\/wp\/v2\/posts\/388\/revisions\/729"}],"wp:attachment":[{"href":"https:\/\/830519.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=388"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/830519.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=388"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/830519.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=388"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}