shell只显示当前目录,默认显示完整的目录,进入深层次目录导致很长

vim ~/.bashrc
if [ "$color_prompt" = yes ]; then
    #默认设置 \w 完整目录
    #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    #我的设置 \W 当前目录
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi

统计git提交次数: 所有人的所有提交次数,会展示所有的提交人 提交次数详情。

git log | grep "^Author: " | awk '{print $2}' | sort | uniq -c | sort -k1,1nr

统计时间内提交次数。

git log --author=joyber --after="2023-01-01" --before="2023-12-31" --no-merges | grep -e 'commit [a-zA-Z0-9]*' | wc -l

统计时间内提交的备注内容(只保留提交时间和备注内容),放到桌面。

git log --author=joyber --after="2023-01-01" --before="2023-12-31" --no-merges | grep -v '^commit' | grep -v '^Author' > ~/Desktop/gitstat.txt

统计时间内提交的备注内容(只保留备注内容),放到桌面。

git log --author=joyber --after="2023-01-01" --before="2023-12-31" --no-merges | grep -v '^commit' | grep -v '^Author' | grep -v '^Date' > ~/Desktop/gitstat1.txt

去除连续提交的重复多次的相同内容

cat gitstat1.txt | grep -v '^$' | uniq > gitstat2.txt

先排序,再去除重复的行

sort -u gitstat1.txt > gitstat2.txt
#or
sort gitstat1.txt | uniq > gitstat2.txt

统计提交行数:根据1展示出详情,可以填入username。将展示该用户增加行数,删减行数,剩余行数。

git log --author="joyber" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -

前言:图片+音频合成-让图片说话
默认PaddlePaddle已安装

1、下载PaddleGAN代码

cd /home/aistudio
git clone https://gitee.com/PaddlePaddle/PaddleGAN

2、本地安装PaddleGAN

cd /home/aistudio/PaddleGAN
python3 -m pip install -v -e .

3、唇形动作合成命令使用说明

cd applications/
python3 tools/wav2lip.py \
--face /home/aistudio/1.jpeg \
--audio /home/aistudio/2.m4a \
--outfile /home/aistudio/pp_put.mp4

face: 原始视频,视频中的人物的唇形将根据音频进行唇形合成
audio:驱动唇形合成的音频,视频中的人物将根据此音频进行唇形合成
outfile:参数指定的视频文件,该文件即为和音频同步的视频文件

centos6.9安装fail2ban防爆破软件实操
看下防火墙服务是否开启启动

chkconfig --list|grep iptables

查看当前运行的端口

netstat -tnlp

查看当前防火墙状态

service iptables status
iptables -L -n

添加配置防火墙端口,把需要开放的端口都添加进去

iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 5060 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
iptables -A INPUT -p tcp --dport 6379 -j ACCEPT
iptables -A INPUT -p tcp --dport 7088 -j ACCEPT
iptables -A INPUT -p tcp --dport 10050 -j ACCEPT
iptables -A INPUT -p tcp --dport 10051 -j ACCEPT

#保存配置,不然重启后就没有了

service iptables save 

#安装fail2ban

wget https://codeload.github.com/fail2ban/fail2ban/zip/refs/tags/0.9.7 -O fail2ban.0.9.7.zip
unzip fail2ban.0.9.7.zip
cd fail2ban-0.9.7
python setup.py install

#添加启动脚本

cp files/redhat-initd /etc/init.d/fail2ban

#配置fail2ban

cd /etc/fail2ban/
cp jail.conf jail.d/jail.conf.local
cd jail.d
vim jail.conf.local

找到[sshd]配置段,将这行以前的都删除,以及后面的 [sshd-ddos] 之后的配置段内容都删除(也就是只需要下面的配置就可以了)
更新为以下配置(port端口自己改成服务器的ssh端口号)

[sshd]
enabled = true
# To use more aggressive sshd filter (inclusive sshd-ddos failregex):
#filter = sshd-aggressive
filter = sshd
port = ssh
#port    = 5060
action = iptables[name=SSH,port=ssh,protocol=tcp]
#action = iptables[name=SSH,port=5060,protocol=tcp]
sendmail-whois[name=SSH,dest=root,sender=joyber@qq.com]
logpath = /var/log/secure
maxretry = 3
findtime = 300
bantime = 86400

[sshd-ddos]
# This jail corresponds to the standard configuration in Fail2ban.
# The mail-whois action send a notification e-mail with a whois request
# in the body.
port    = ssh
#port    = 5060
logpath = %(sshd_log)s
backend = %(sshd_backend)s

解决fail2ban在执行 iptables 命令报错 -w 需要参数的问题

cd /etc/fail2ban/action.d
vim iptables-common.conf
#把 lockingopt = -w 这一行注掉,改成这样的空配置
#lockingopt = -w
lockingopt = 

重启防火墙和fail2ban

service iptables restart
service fail2ban start

有些系统可能安装后fail2ban-client等执行文件并没有在/usr/bin/fail2ban-client这个路径
需要修改一下启动脚本

vim /etc/init.d/fail2ban

#FAIL2BAN="/usr/bin/fail2ban-client"
FAIL2BAN="/usr/local/bin/fail2ban-client"

查看日志文件,是否有报错

tail -f /var/log/fail2ban.log

最后就是自己找一个测试机测试一下,一直输入错误的密码是否会被禁止访问了

ssh 47.100.31.xxx
#被禁止访问了
ssh: connect to host 47.100.31.xxx port 22: Connection refused

#查看fail2ban运行状态和禁止的IP列表等信息
fail2ban-client status
fail2ban-client status sshd

测试成功后如果 iptables 没有自启动的话,可以这样开启

chkconfig iptables on