du -h / | sort -rh | head -20
find / -type f -exec du -sb {} + | awk '{ size_gb = $1 / (1024*1024*1024); printf "%.2fGB\t%s\n", size_gb, $2 }' | sort -nr | head -n 20
awk 'FNR==1 {print FILENAME} {print}' *.conf | less
grep -Ev '^\s*($|#|;)' example.conf
find . -type f -name "*.zip" -printf "%T@ %p\n" | sort -nr | tail -n +2 | awk '{print $2}' | xargs rm -f
tar -cf - test | pigz -p 3 > test.tar.gz
ss -ano | awk '{print $2}' | sort -n | uniq -c | sort
echo <passwd> | passwd root --stdin
# salt批量修改密码
python3 -c "import crypt; print(crypt.crypt('your_password', crypt.mksalt(crypt.METHOD_SHA512)))"
salt '*' shadow.set_password root '<hashed_password>'
find /data/app/tmp -mtime +30 -name "*.flv" -exec rm -Rf {} \;
sed -ri 's/.*swap.*/#&/' /etc/fstab && swapoff -a
PASSWORD=$(base64 < /dev/urandom | head -c16); echo "$PASSWORD"; echo -n "$PASSWORD" | sha1sum | tr -d '-' | xxd -r -p | sha1sum | tr -d '-'
for file in $(ls); do sed -i 's/nmg/sz/g' "$file"; done
docker build --build-arg https_proxy=127.0.0.1:8088
apt-get install dpkg-repack
# 保存主软件包
dpkg-repack telnet
apt-get download telnet
# 保存主软件包和所有依赖
apt-cache depends telnet
# 导入包
dpkg -i telnet.deb
USERNAME=muen-admin;
PASSWORD=$(base64 < /dev/urandom | head -c16);
echo "USERNAME:$USERNAME,PASSWORD:$PASSWORD";docker run --rm \
--entrypoint htpasswd \
httpd:alpine \
-mbn $USERNAME $PASSWORD > nginx.htpasswd
# -mbn Force MD5 encryption
# -Bbn Force bcrypt encryption
ssh-keygen -t rsa -P '' -f /root/.ssh/id_rsa
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
# 然后保存/root/.ssh/id_rsa用于连接
# 查看源端口为40000端口的,客户端连接按数量排序前50个
ss -tn sport = :40000 | awk '{print $5}' | cut -d':' -f1 | sort | uniq -c | sort -nr | head -n 50
# 去重连接数
ss -tn sport = :40000 | awk 'NR > 1 {print $4}' | cut -d':' -f1 | sort -u | wc -l
# 总连接数
ss -ano | grep 40000 | wc -l
-M
后面传0
就是随机在远程主机上32768-65535
开一个端口来监听,如果传自定义值就是指定端口监听
注:还是会监听22
端口
yum install -y autossh
autossh -M 0 -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -NfR *:11000:172.168.1.1:6061 root@172.168.1.1
docker image prune -a
docker system df
docker builder prune -a
docker system prune -a
#!/bin/bash
cmd_status=1
while [ ${cmd_status} != 0 ]; do
# rsync -rP -e "ssh -i /root/test.pem" /data/app/ 192.168.1.1:/data/app/
# 1M/s
# yum install nc -y
# apt install -y netcat-openbsd
# 老版本 nc -x
# rsync -rP --bwlimit=1024 --rsh="ssh -o ProxyCommand='nc -x x.x.x.x:44066 %h %p'" ${des_dir}/ root@${ip}:${src_dir}/${sync_file}
# 新版本 nc --proxy-type socks5 --proxy ${ip}:${port}
# rsync -rP --bwlimit=1024 --rsh="ssh -o ProxyCommand='nc --proxy-type socks5 --proxy-auth username:password --proxy x.x.x.x:44066 %h %p'" ${des_dir}/ root@${ip}:${src_dir}/${sync_file}
rsync -rP --bwlimit=1024 --rsh="ssh" /data/baksvn/20200906 root@172.31.37.123:/data/baksvn/
cmd_status=$?
done
如果要使用其他用户传输: rsync -e 'ssh -l <user>'
curl
使用代理# socks5代理
curl -x socks5h://user:xxx@192.168.1.1:1080
# 需要用到dos2unix包
find . -type f -exec dos2unix {} \;
#!/bin/bash
parse_commandline() {
while test $# -gt 0
do
key="$1"
case "$key" in
-i|--install-dir)
PARSED_INSTALL_DIR="$2"
shift 2
;;
-b|--bin-dir)
PARSED_BIN_DIR="$2"
shift 2
;;
-u|--update)
PARSED_UPGRADE="yes"
shift
;;
-h|--help)
usage
exit 0
;;
*)
die "Got an unexpected argument: $1"
;;
esac
done
}
usage() {
echo "Usage: scriptname [options]"
echo "Options:"
echo " -i, --install-dir Specify installation directory"
echo " -b, --bin-dir Specify binary directory"
echo " -u, --update Update the installation"
echo " -h, --help Show this help message"
}
die() {
echo "$@" >&2
exit 1
}
parse_commandline "$@"
echo "Install directory: $PARSED_INSTALL_DIR"
echo "Bin directory: $PARSED_BIN_DIR"
temp_file_name="temp_database.csv"
exclude_list="
aaa
"
function exclude_database {
file=$1
rm -f ${file}
line_num=0
for instance in $(cat ${temp_file_name}|egrep -v "^#");do
id=$(echo "${instance}" |awk -F ',' '{print $1}')
excluded=false
for excluded_item in $exclude_list; do
if [[ "$id" == "$excluded_item" ]]; then
excluded=true
break
fi
done
if [ "$excluded" == false ]; then
echo "${instance}" >> ${file}
fi
done
rm -f ${temp_file_name}
}
cat << EOF >> /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.core.somaxconn=65535
net.ipv4.tcp_max_tw_buckets=1440000
net.ipv4.ip_local_port_range=1024 65000
net.ipv4.tcp_tw_reuse=1
net.ipv4.tcp_fin_timeout=15
EOF
sysctl -p
yum install -y epel-release
yum install -y iperf3
# 默认端口 5201
# 服务端
iperf3 -s
# 客户端
# 上传
iperf3 -c <server_ip>
# 下载
iperf3 -c <server_ip> -R