BAD PASSWORD: The password fails the dictionary check – it is based on a dictionary word

在Linux系统上有的时候需要设置简单的root密码(可能只是为了测试), 有的发行版会出现下面的提示:

BAD PASSWORD: The password fails the dictionary check - it is based on a dictionary word

解决办法有很多,但是最简单的方式就是:

编辑

nano /etc/security/pwquality.conf

添加或者修改

dictcheck=0

这样就可以使用passwd设置弱密码了

Linux Journal 的日志太大

位于/var/log/journal文件夹下面的journal 日志太大,一般系统限制为4GB, 对于一些硬盘比较小的VM就不太友好了

这个是由systemd-journal引起的,我们需要clean it 和limit its growth

Clean Existing Logs

Check current disk usage:

journalctl --disk-usage

Delete logs older than a certain time (e.g., 7 days):

journalctl --vacuum-time=7d

Or limit total size (e.g., 500MB):

journalctl --vacuum-size=500M

Or keep only N logs (e.g., last 10 boots):

journalctl --vacuum-files=10

 

Prevent Logs from Growing Too Large

Edit the persistent journal configuration:

sudo nano /etc/systemd/journald.conf

Look for or add these lines:

SystemMaxUse=500M
SystemKeepFree=100M
SystemMaxFileSize=100M
SystemMaxFiles=10

Then restart systemd-journald:

sudo systemctl restart systemd-journald

 

(Optional) Disable Persistent Journaling

If you don’t need persistent logs across reboots:

sudo rm -rf /var/log/journal
sudo mkdir /run/log/journal
sudo systemctl restart systemd-journald

This means logs will be lost after reboot.

对于我个人来说,我喜欢做如下设置:

journalctl --vacuum-size=200M

然后在/etc/systemd/journald.conf 中设置

SystemMaxUse=200M

SystemMaxFileSize=100M

最后重启journald服务

systemcl restart systemd-journald

压缩文件的MD5值的变化

即便是同一个文件夹的压缩文件,如果压缩的时间不一样,那么产生的压缩文件的md5值也是不一样的。

原因有三个:

1 Timestamps in Metadata – Many compression tools store file timestamps (creation, modification, and access times) inside the archive. If you compress the same folder at different times, these timestamps may differ, leading to a different MD5 hash.

2 Compression Algorithm Variations – Some compression tools use different compression settings, even if the same files are inside. Small variations in compression level or metadata can result in a different output file and a different MD5 hash.

3 Order of Files – If the compression tool does not always process files in the same order, the resulting archive may be structured differently, leading to a different MD5 hash.

如果想得到固定的MD5值,可以使用如下的三个方法:

1 Hash Individual Files – Instead of hashing the compressed folder, compute MD5 hashes for each file inside the folder and compare them.
2 Use Deterministic Compression – Some tools (like tar –sort=name with gzip –no-name) help create archives with consistent metadata.
3 Exclude Timestamps – Some formats allow you to omit timestamps (e.g., zip –latest-time).

Curl 常用commands

经常利用curl 来测试网站的一些301/302转向,检查代码什么的.

下面是常用的命令, 这里保存一下,经常用的上. 

curl -o vue-v2.6.10.js https://cdn.jsdelivr.net/npm/vue/dist/vue.js 
#vue.js 保存为vue-v2.6.10.js
curl -O https://cdn.jsdelivr.net/npm/vue/dist/vue.js  
# -O 直接保存为原文件名
curl -I  https://www.ubuntu.com/  
# 获得HTTP HEADER
curl -I --http2 https://www.ubuntu.com 
# --https2 检查是否支持http2协议
curl -L google 
# -L 命令curl 跟随跳转到final destination
curl -A "googlebot" https://www.ubuntu.com 
# -A 自定义UA
curl -x 192.168.66.1:8888 http://linux 
# -x 或者 --proxy 设定proxy
curl -H "X-Header: value" https://www.keycdn.com 
# -H 自定义header
curl -H "X-Header: value" https://www.keycdn.com -v 
# -v 表示 verbose
curl -h # -h 表示manual
curl --request GET/POST https://www.keycdn.com  
# curl 默认是GET, --request 可以自定为GET或者POST

Debian 9/10 编译安装nginx

Debian 9, Debian 10 都适用于此教程.

实际上,Nginx 的官方repo编译的nginx,已经把能加上的module全部都加上了,因此在一般情况下,建议使用nginx的官方repo来安装nginx. 但是如果说你想添加第三方的module,或者使用最新的openssl 的话,在或者更改一下nginx 的安装路径的话,就需要自己编译了. 此篇教程尽量按照nginx官方repo的configure来编译安装openssl.

在一台全新安装的Debian 9或者Debian 10上:

更多

Debian 9, Debian 10 以及Ubuntu 关闭IPv6

用netinst.iso 安装的debian 和 ubuntu,默认都会开启IPv6,但是很多服务商并不分配IPv6,因此大部分的时候我们需要将IPv6 关闭。主要有两种办法,一个是修改sysctl.conf, 或者是在/etc/sysctl.d 目录下创建一个.conf 文件

Method 1:

编辑/etc/sysctl.conf 文件,在文件的最末尾添加下面的entry:

net.ipv6.conf.all.disable_ipv6 = 1

如果仅想关闭某一网卡的ipv6,比如说ens4, 那就可以添加下面的entry:

net.ipv6.conf.ens4.disable_ipv6 = 1

让命令生效:

sysctl -p

Method 2:

在/etc/sysctl.d 目录下创建70-disable-ipv6.conf

nano /etc/sysctl.d/70-disable-ipv6.conf

添加下面的entry:

net.ipv6.conf.all.disable_ipv6 = 1

如果仅仅想关闭某一网卡,比如说ens4, 添加下面的entry:

net.ipv6.conf.ens4.disable_ipv6 = 1

立刻生效:

sysctl -p -f /etc/sysctl.d/70-disable-ipv6.conf

就是这么简单

 

 

Debian 9 开启 BBR

Debian 9 和 10 的内核自带了google 开发的 BBR 拥塞算法,我们可以很方便的开启BBR 进行访问加速

开启方法:

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

如果执行之后没有报错,重启一下系统就可以让配置生效.

重启之后,执行如下命令查看内核是否已开启BBR:

sysctl net.ipv4.tcp_available_congestion_control

显示以下即已开启:

root@localhost:~# sysctl net.ipv4.tcp_available_congestion_control
net.ipv4.tcp_available_congestion_control = bbr cubic reno

查看BBR是否启动:

lsmod | grep bbr

显示以下即启动成功:

root@localhost:~# lsmod | grep bbr
tcp_bbr 16384 14