Buta Sticky Notes
本文最后更新于:3 年前
日常解决问题基本靠 Google,拿来水博客跟 ** Copy&Paste 也没啥区别,但是又想把这些方法记录下来,万一以后需要用还方便查看,于是打算全部写在这一篇文章里了。
当然,为了防止未来的我忘记当时写的是什么东西,咱尽量将一些因人而异、因机而异的东西标注出来(比如每段的 Replacement),但难免有疏漏,如果有读者能够看到,并感到疑惑,请不要吝啬你的留言。
为 Docker 设置代理
2020-10-13T06:59:27UTC
在这个文件夹
/etc/systemd/system/docker.service.d(没有就新建一个)里创建一个http-proxy.conf文件。内容这样写:
1
2[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/"然后刷新
systemd配置:1
sudo systemctl daemon-reload检查一下:
1
systemctl show --property=Environment docker重启 docker
1
sudo systemctl restart docker
Systemd 配置 clash service
2020-10-13T06:59:27UTC
编辑
/usr/lib/systemd/system/clash.service:1
2
3
4
5
6
7
8
9
10
11
12
13
14# edit and save this file to /usr/lib/systemd/system/clash.service
[Unit]
Description=clash
After=network.target
[Service]
WorkingDirectory=[your home directory]/.config/clash
ExecStart=[your home directory]/.config/clash/start-clash.sh
ExecStop=[your home directory]/.config/clash/stop-clash.sh
Environment="HOME=[your home directory]"
Environment="CLASH_URL=[your subscription url]"
[Install]
WantedBy=multi-user.targetReplacement:
[your home directory],[your subscription url]Clash 启动脚本:
编辑
[your home directory]/.config/clash/start-clash.sh1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#!/bin/bash
# save this file to ${HOME}/.config/clash/start-clash.sh
# save pid file
echo $$ > ${HOME}/.config/clash/clash.pid
diff ${HOME}/.config/clash/config.yaml <(curl -s ${CLASH_URL})
if [ "$?" == 0 ]
then
/usr/bin/clash
else
TIME=`date '+%Y-%m-%d %H:%M:%S'`
cp ${HOME}/.config/clash/config.yaml "${HOME}/.config/clash/config.yaml.bak${TIME}"
curl -L -o ${HOME}/.config/clash/config.yaml ${CLASH_URL}
/usr/bin/clash
fiClash 停止脚本
编辑
[your home directory]/.config/clash/stop-clash.sh1
2
3
4
5
6
7#!/bin/bash
# save this file to ${HOME}/.config/clash/stop-clash.sh
# read pid file
PID=`cat ${HOME}/.config/clash/clash.pid`
kill -9 ${PID}
rm ${HOME}/.config/clash/clash.pid上面几个文件给个权限(
chmod)-
1
2systemctl enable clash
systemctl start clash
编辑订阅文件
2020-10-14T04:41:20UTC
1 | |
例如订阅里写的外部控制为 localhost:9090,而我想改为 :9090,可以用 sed 来替换。然后写到 start-clash.sh 里。
6c 代表第六行。
自用 Shell 小脚本:配置代理
2020-10-13T06:59:27UTC
1 | |
用法:
proxy 设置置本地代理,端口为 HTTP 7890proxy <address> 设置代理,可以选择预设的地址或者输入其他地址proxy <address> <port> 设置代理,地址和端口
Linux 开机挂载 SMB
2020-10-13T06:59:27UTC
Replacement:
[]
用
id [USERNAME]([USERNAME]为本机用户名) 为用户名查看uid和gid。编辑
cred文件,例如~/.smbcredential(名字、位置随意):1
2username=[SMB_USERNAME]
password=[SMB_PASSWORD]编辑
/etc/fstab:1
//[Addredd]/[Path] /[MountPoint] cifs uid=[UID],gid=[GID],cred=[PathToCredential]例如
1
//10.0.0.1/Files /media/router cifs uid=1000,gid=1000,cred=/home/ubuntu/.smbcredential
问题
mount error(2): No such file or directory
1 | |
尝试给挂载命令加个版本(默认 SMB 为 3.0),尝试更改到 2.0。vers=2.0
1 | |
zsh_history 不记录错误命令
2020-10-31T03:32:11UTC
.zshrc 中:
1 | |