VPS 常用命令和软件

VPS 常用命令和软件

系统相关

  • 非 root 的机器上获取 root 用户权限
1
sudo -i
  • 修改为默认 root 用户登录
1
echo "root:你自定义的root用户密码" | sudo chpasswd root && sudo sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config && sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config && sudo service ssh restart && sudo reboot && echo "Password changed successfully and SSH configuration updated. Restarting Server…" || echo "Failed to change password or update SSH configuration"
  • 系统更新与安装依赖包

    • debian 和 ubuntu 系统
    1
    apt update -y && apt install -y curl
    • alpine 系统
    1
    apk add curl && apk add bash && apk add sudo
  • 系统换源

    • debian9 系统
    1
    wget -O /etc/apt/sources.list https://static.lty.fun/%E5%85%B6%E4%BB%96%E8%B5%84%E6%BA%90/SourcesList/Debian-9-archive.list
    • LXC 乌班图 20 系统
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    cat > /etc/apt/sources.list <<EOF
    deb http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ focal-proposed main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ focal-proposed main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse
    EOF
  • 系统重启

1
reboot
  • 添加 swap 交换分区
1
curl -L https://raw.githubusercontent.com/spiritLHLS/addswap/main/addswap.sh -o addswap.sh && chmod +x addswap.sh && bash addswap.sh
  • BBR 加速
1
wget -N --no-check-certificate "https://raw.githubusercontent.com/chiakge/Linux-NetSpeed/master/tcp.sh" && chmod +x tcp.sh && ./tcp.sh
  • 查看 VPS 的 IP 与网络信息
1
ip a

防火墙相关

debian 和 ubuntu 系统,其他系统不知道

  • 安装防火墙
1
apt-get install firewalld -y && firewall-cmd --zone=public --add-port=22/tcp --permanent && firewall-cmd --reload
  • 开放指定端口
1
firewall-cmd --zone=public --add-port=端口/tcp --permanent && firewall-cmd --reload
  • 停止防火墙
1
systemctl stop firewalld
  • 禁用防火墙
1
systemctl disable firewalld
  • 防火墙端口放行
1
ufw allow 端口号

安装 docker

1
2
3
curl -sSL https://get.docker.com/ | sh
systemctl start docker
systemctl enable docker

安装面板

  • 科技蓝系统优化与建站

    • github 官方源
    1
    curl -sS -O https://raw.githubusercontent.com/kejilion/sh/main/kejilion.sh && chmod +x kejilion.sh && ./kejilion.sh
    • 国内加速源
    1
    curl -sS -O https://raw.gitmirror.com/kejilion/sh/main/cn/kejilion.sh && chmod +x kejilion.sh && ./kejilion.sh
  • 宝塔面板:主要用于建站

    • 乌班图系统
    1
    wget -O install.sh https://download.bt.cn/install/install-ubuntu_6.0.sh && sudo bash install.sh ed8484bec
    • debian 系统
    1
    wget -O install.sh https://download.bt.cn/install/install-ubuntu_6.0.sh && bash install.sh ed8484bec
    • 万能版
    1
    if [ -f /usr/bin/curl ];then curl -sSO https://download.bt.cn/install/install_panel.sh;else wget -O install_panel.sh https://download.bt.cn/install/install_panel.sh;fi;bash install_panel.sh ed8484bec
  • 1panel 面板:主要用于建站

1
curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && sudo bash quick_start.sh
  • 哪吒探针:用户监控 VPS 的状态

    教程:安装 Dashboard | 哪吒监控

    • github 官方源
    1
    curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/install.sh -o nezha.sh && chmod +x nezha.sh && sudo ./nezha.sh
    • 国内加速源
    1
    curl -L https://gitee.com/naibahq/nezha/raw/master/script/install.sh -o nezha.sh && chmod +x nezha.sh && sudo CN=true ./nezha.sh

搭建节点

  • 申请 CF 的 acme 证书

    • Misaka15 年证书脚本

      15 年证书,先到 cf 绑定域名并申请源服务器证书

    1
    wget -N --no-check-certificate https://raw.githubusercontent.com/Misaka-blog/acme-script/main/acme.sh && bash acme.sh
    • 甬哥证书申请脚本
    1
    bash <(curl -Ls https://gitlab.com/rwkgyg/acme-script/raw/main/acme.sh)
  • 搭建 x-ui 面板

    • FranzKafkaYu 版
    1
    bash <(curl -Ls https://raw.githubusercontent.com/FranzKafkaYu/x-ui/master/install.sh)
    • sing-web 版
    1
    bash <(wget -qO- https://raw.githubusercontent.com/sing-web/x-ui/main/install_CN.sh)
    • 甬哥版
    1
    bash <(curl -Ls https://raw.githubusercontent.com/yonggekkk/x-ui-yg/main/install.sh)
    • Misaka 的 3x-ui
    1
    bash <(curl -Ls https://raw.githubusercontent.com/Misaka-blog/3x-ui/master/install.sh)
    • alpine 系统专用版
    1
    apk add curl && apk add bash && bash <(curl -Ls https://raw.githubusercontent.com/Lynn-Becky/Alpine-x-ui/main/alpine-xui.sh)
  • HY2 脚本

    V4 机器需使用 warp 的情况下,需要先安装 HY2 脚本

1
wget -N --no-check-certificate https://raw.githubusercontent.com/Misaka-blog/hysteria-install/main/hy2/hysteria.sh && bash hysteria.sh
  • Argo 类脚本

    不能与 X-UI 面板共存

    • ArgoX 脚本(fscarmen)
    1
    bash <(wget -qO- https://raw.githubusercontent.com/fscarmen/argox/main/argox.sh)
    • 梭哈脚本(白嫖哥)
    1
    curl [https://www.baipiao.eu.org/suoha.sh](https://www.baipiao.eu.org/suoha.sh) -o suoha.sh && bash suoha.sh
    • 全能脚本
    1
    curl -fsSL https://raw.githubusercontent.com/eooce/ssh_tool/main/ssh_tool.sh -o ssh_tool.sh && chmod +x ssh_tool.sh && ./ssh_tool.sh
  • WARP 脚本

    • fscarmen 版 warp
    1
    wget -N https://gitlab.com/fscarmen/warp/-/raw/main/menu.sh && bash menu.sh[option] [lisence/url/token]
    • 甬哥版多功能 warp
    1
    bash <(wget -qO- https://gitlab.com/rwkgyg/CFwarp/raw/main/CFwarp.sh 2> /dev/null)
    • 甬哥多平台优选 WARP 对端 IP + 无限生成 WARP-Wireguard 配置 手机版
    1
    curl -sSL https://gitlab.com/rwkgyg/CFwarp/raw/main/point/endip.sh -o endip.sh && chmod +x endip.sh && bash endip.sh
    • CMliu warp 优选 IP 并生成 clash 配置文件
    1
    wget -N -P Warp2Clash https://raw.githubusercontent.com/cmliu/Warp2Clash/main/W2C_start.sh && cd Warp2Clash && chmod +x W2C_start.sh