Linux服务器常用脚本以及常用命令记录

机子拿到手第一件事是什么?卸载阿里云监控、测基本参数、安装面板?为了方便大家使用,在此做一个记录:

常用命令

1、更新系统环境以及修改默认密码、SSH端口号防止被爆破

#更新系统软件包列表
apt-get update && apt-get upgrade -y

#修改系统密码
passwd

#一键修改SSH端口,只支持Debian/Ubuntu
wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubiBackup/doubi/master/ssh_port.sh && chmod +x ssh_port.sh && bash ssh_port.sh

2、安装必要软件依赖

apt update -y && apt install -y curl && apt install -y socat && apt install -y wget && apt install -y git && apt install sudo -y

3、BBR开启(提速必备)

wget -N --no-check-certificate "https://github.000060000.xyz/tcp.sh" && chmod +x tcp.sh && ./tcp.sh
或
wget -O tcp.sh "https://git.io/coolspeeda" && chmod +x tcp.sh && ./tcp.sh

4、安装swap(非必装)

bash <(wget -qO- https://fool.im/swap.sh)

5、docker和docker-compose(非必装)

#下载docker
wget -qO- get.docker.com | bash

#设置docker开机自启
systemctl enable docker

#重启docker
systemctl restart docker

#查看docker版本
docker --version

#安装docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

#docker-compose赋权
sudo chmod +x /usr/local/bin/docker-compose

#查看docker-compose版本
docker-compose --version

常用脚本

1.一键网络重装系统 – 魔改版(适用于Linux / Windows)

wget --no-check-certificate -qO ~/Network-Reinstall-System-Modify.sh 'https://www.cxthhhhh.com/CXT-Library/Network-Reinstall-System-Modify/Network-Reinstall-System-Modify.sh' && chmod a+x ~/Network-Reinstall-System-Modify.sh && bash ~/Network-Reinstall-System-Modify.sh -UI_Options

#Windows系统默认账号密码:Administrator/cxthhhhh.com
#Linux系统默认账号密码:root/cxthhhhh.com

2.VPS综合测试脚本

#Linux 测试脚本,支持speedtest测速、丢包率、Geekbench v5、流媒体解锁等测试
bash <(wget -qO- https://down.vpsaff.net/linux/speedtest/superbench.sh)
#跳过Geekbench和国际speedtest测试
bash <(wget -qO- https://down.vpsaff.net/linux/speedtest/superbench.sh) -f

#综合测试脚本
wget git.io/vpstest && bash vpstest

#测试硬盘IO
curl -sL yabs.sh | bash

#不带测速
curl -sL yabs.sh | bash -s -- -i

3.三网测速脚本

bash <(curl -Lso- https://bench.im/hyperspeed)
或
bash <(curl -Lso-  https://git.io/superspeed_uxh)

4.最新内核脚本 锐速/BBRPLUS/BBR2

卸载内核

wget -N --no-check-certificate "https://github.000060000.xyz/tcp.sh" && chmod +x tcp.sh && ./tcp.sh
或
wget -O tcp.sh "https://git.io/coolspeeda" && chmod +x tcp.sh && ./tcp.sh

不卸载内核

wget -N --no-check-certificate "https://github.000060000.xyz/tcpx.sh" && chmod +x tcpx.sh && ./tcpx.sh
或
wget -O tcpx.sh "https://git.io/JYxKU" && chmod +x tcpx.sh && ./tcpx.sh

Centos 8.0/Ubuntu 20.04/Debian 8 开启BBR命令:

echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p
sysctl -n net.ipv4.tcp_congestion_control
lsmod | grep bbr

5.流媒体解锁检测

```
#融合测试
bash <(wget -qO- --no-check-certificate https://gitlab.com/spiritysdx/za/-/raw/main/ecs.sh)

#tiktok检测
bash <(curl -s https://raw.githubusercontent.com/lmc999/TikTokCheck/main/tiktok.sh)

#第一个
bash <(curl -L -s https://raw.githubusercontent.com/lmc999/RegionRestrictionCheck/main/check.sh)

# 第二个
bash <(curl -sSL "https://github.com/CoiaPrant/MediaUnlock_Test/raw/main/check.sh")

# 第三个
bash <(curl -L -s check.unlock.media)

# 第四个
bash <(curl -Ls unlock.moe)

# 检测Netflix:

wget -O nf https://github.com/sjlleo/netflix-verify/releases/download/2.6/nf_2.6_linux_amd64 && chmod +x nf && clear && ./nf -method full

# 一键检测youtube和奈飞:

wget -O tubecheck https://github.com/sjlleo/TubeCheck/releases/download/1.0Beta/tubecheck_1.0beta_linux_amd64 && chmod +x tubecheck && clear && ./tubecheck

# 抖音解锁脚本
bash <(curl -s https://raw.githubusercontent.com/lmc999/TikTokCheck/main/tiktok.sh)
```

6.回程路由测试:

# vps回程一键脚本|TCP回程|ICMP回程|IPV6回程测试
wget https://raw.githubusercontent.com/vpsxb/testrace/main/testrace.sh -O testrace.sh && bash testrace.sh

# 三网线路测试
curl https://raw.githubusercontent.com/zhucaidan/mtr_trace/main/mtr_trace.sh|bash

# 三网上传下载
bash <(curl -Lso- https://git.io/superspeed_uxh)    //国际


# 四网回程路由节点测试
wget https://raw.githubusercontent.com/nanqinlang-script/testrace/master/testrace.sh
bash testrace.sh

# 节点服务器回程测试线路
wget -qO- git.io/autobesttrace | bash

# 带详细线路
wget --no-check-certificate https://tutu.ovh/bash/returnroute/route && chmod +x route && clear && ./route

# 带详细线路
curl https://raw.githubusercontent.com/zhanghanyun/backtrace/main/install.sh -sSf | sh

# 回程路由测试
wget -qO- git.io/autobesttrace | bash
```

7.安装ca-certificates解决证书不被信任问题

#centos
yum install -y wget && yum install -y ca-certificates

#debian/ubuntu
apt-get install -y wget && apt-get install -y ca-certificates

8.测试VPS是否开放25端口

apt update
apt install telnet
telnet smtp.aol.com 25

9.内存检测脚本

检测VPS真实可分配内存的小工具,适用于检测VPS超售情况。本程序检测的可分配内存指的是用户使用时最大能占用的内存量。

#CentOS / RHEL
yum install wget -y
yum groupinstall "Development Tools" -y
wget https://raw.githubusercontent.com/FunctionClub/Memtester/master/memtester.cpp
gcc -l stdc++ memtester.cpp
./a.out

#Ubuntu / Debian
apt-get update
apt-get install wget build-essential -y
wget https://raw.githubusercontent.com/FunctionClub/Memtester/master/memtester.cpp
gcc -l stdc++ memtester.cpp
./a.out

10.魔改 OpenVZ 开启 GoogleBBR

适用于基于OpenVZ虚拟机上的 Debian or Ubuntu。

#单网卡(单 IP) 服务器:
wget https://github.com/tcp-nanqinlang/lkl-rinetd/releases/download/1.1.0/tcp_nanqinlang-rinetd-debianorubuntu.sh
bash tcp_nanqinlang-rinetd-debianorubuntu.sh

#多网卡(多 IP) 服务器,会为所有网卡(所有 IP)提供加速:
wget https://github.com/tcp-nanqinlang/lkl-rinetd/releases/download/1.1.0/tcp_nanqinlang-rinetd-debianorubuntu-multiNIC.sh
bash tcp_nanqinlang-rinetd-debianorubuntu-multiNIC.sh

11.一键安装openlitespeed+mraiodb+lsphp7.3环境和Wordpress

#Usage:
wget --no-check-certificate https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh && bash ols1clk.sh -w --adminpassword mypassword --email myemail@qing.su --lsphp 73 --wordpressplus mydomain.qing.su --wordpresspath /srv/www/mydomain.qing.su/public_html/ --dbrootpassword myrootpassword --dbname mywordpressdb --dbuser mywordpressdbuser --dbpassword mywordpressdbpassword --listenport 80 --wpuser mywpuser --wppassword mywppassword --wplang zh_CN
#Note
-w 安装wordpress
–adminpassword 后面加上你设定的OpenLiteSpeed后台管理员密码
–email 后面跟你的WordPress管理员邮箱
–lsphp 后面加上你想要安装的PHP版本,比如7.3就输入73, 5.6就输入56.
–wordpressplus 后面加上你的WordPress域名。请提前将该域名解析到这台VPS或者服务器上。
–wordpresspath 后面跟WordPress的安装路径。
–dbrootpassword 后面加上MariaDB数据库root用户的密码。
–dbname 后面加上你需要新建的WordPress的数据库名。
–dbuser 后面加上你需要新建的WordPress的数据库用户名。
–dbpassword 后面加上你需要新建的WordPress的数据库密码。
–listenport 后面加上网站的端口,默认是80。
–wpuser 后面加上你需要新建的WordPress的管理员用户名。
–wppassword 后面加上你需要新建的WordPress的管理员密码。
–wplang 后面加上WordPress语言,如果需要中文,填zh_CN; 如果需要英文,填en.

12.测试IP质量(仅供参考)

bash <(wget -qO- --no-check-certificate https://gitlab.com/spiritysdx/za/-/raw/main/qzcheck.sh)

13.测试是否解锁OpenAI

bash <(curl -Ls https://cpp.li/openai)
bash <(curl -Ls https://cdn.jsdelivr.net/gh/missuo/OpenAI-Checker/openai.sh)