Skip to content

VPS 常用脚本及配置

软件包

https://www.nodeseek.com/post-35937-2#14

txt
wget curl nano vim sudo unzip mtr-tiny iputils-ping bind9-host dnsutils net-tools lsb-release ca-certificates bash-completion fail2ban dialog netbase iproute2 whois ssh dbus systemd systemd-sysv ifupdown locales apt-utils gnupg2 apt-transport-https rsyslog logrotate less rsync haveged systemd-timesyncd iperf3

强迫症必备

https://www.nodeseek.com/post-284926-1

  • touch ~/.hushlogin 让当前用户登录 Linux 时,不再显示 MOTD(Message of the Day)和一些欢迎提示信息
  • sed -i '/unset HISTFILE/d; $a\unset HISTFILE' /root/.bashrc Bash 不再把历史记录写入文件(但会保留在内存中,退出 Shell 后丢失)
  • rm -f /root/.bash_history 删除 root 用户的 Bash 历史记录文件
  • history -c 清空当前 Shell 会话里的命令历史(内存中的部分)

美化 SSH

sh
echo "alias ls='ls --color=auto'" >>/root/.bashrc
echo "alias ll='ls --color=auto -lAF'" >>/root/.bashrc
echo "PS1='\[\033[01;31m\]\u\[\033[01;33m\]@\[\033[01;36m\]\h \[\033[01;33m\]\w \[\033[01;35m\]\$ \[\033[00m\]'" >>/root/.bashrc
source /root/.bashrc

Docker

sh
curl -sSL https://get.docker.com/ | sh

YABS

https://github.com/masonr/yet-another-bench-script

sh
# 完整测试(系统信息 + 硬盘测试 + iPerf3 + GeekBench5 + GeekBench6)
curl -sL yabs.sh | bash -s -- -r -5 -6

# 系统信息
curl -sL yabs.sh | bash -s -- -i -d -g

# 磁盘测速
curl -sL yabs.sh | bash -s -- -i -g

# GeekBench 5
curl -sL yabs.sh | bash -s -- -i -d -5

# GeekBench 6"
curl -sL yabs.sh | bash -s -- -i -d

路由追踪

NextTrace

https://github.com/nxtrace/NTrace-core

安装

sh
# /usr/local/bin/nexttrace
curl nxtrace.org/nt |bash

使用

sh
# 基本使用
nexttrace ip/domain

# 快速测试
nexttrace --fast-trace

# 自定义测试
nexttrace --file /path/to/your/iplist.txt

BackTrace

https://github.com/zhanghanyun/backtrace

安装

sh
# 三网回程直接显示
# /usr/bin/backtrace
curl https://raw.githubusercontent.com/zhanghanyun/backtrace/main/install.sh -sSf | sh

使用

sh
backtrace

流媒体解锁

https://github.com/lmc999/RegionRestrictionCheck

sh
bash <(curl -L -s check.unlock.media)

MTProto

https://github.com/cutelua/mtg-dist

安装

sh
bash <(wget -qO- https://git.io/mtg.sh)

卸载

sh
systemctl disable mtg
systemctl stop mtg
rm -f /usr/local/bin/mtg /etc/systemd/system/mtg.service /etc/mtg.toml

Chrony 时间同步

安装

sh
apt-get install chrony

使用

ini
# /etc/chrony/chrony.conf
# 添加 NTP 服务器
server ntp.aliyun.com minpoll 4 maxpoll 10 iburst
server us.pool.ntp.org minpoll 4 maxpoll 10 iburst

启动

sh
systemctl start chronyd
systemctl enable chronyd

验证

sh
chronyc tracking
chronyc -n sources -v

BBR

旧版

直接修改 /etc/sysctl.conf

sh
# Linux 内核版本大于 4.9
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p
sysctl net.ipv4.tcp_available_congestion_control
lsmod | grep bbr

新版

创建 /etc/sysctl.d/*.conf 来单独配置

sh
tee /etc/sysctl.d/99-bbr.conf >/dev/null <<EOF
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr
EOF
sysctl --system
sysctl net.ipv4.tcp_congestion_control
lsmod | grep bbr

更新内核

https://github.com/jinwyp/one_click_script

sh
bash <(curl -Lso- https://git.io/kernel.sh)
关注微信公众号
你认为这篇文章怎么样?
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v3.1.3