合订本

2099-01-01

qa

SSH 相关问题

1.SSH 如何保持连接不自动断开

1
2
3
4
5
cat >> ~/.ssh/config << EOF

Host *
ServerAliveInterval 60
EOF

2.SSH 使用跳板机

1.ProxyJump

1
2
3
4
5
6
Host target
Hostname
IdentityFile
User
Port
ProxyJump jump

2.ProxyCommand

1
2
3
4
5
6
Host target
Hostname
IdentityFile
User
Port
ProxyCommand ssh jump -W %h:%p

3.SSH 滚轮变成浏览历史命令

windows terminal 使用 git bash 的情况下 -> 注释掉 /etc/inputrc 这两行

1
2
bind '"\e[5~": history-search-backward'
bind '"\e[6~": history-search-forward'

Linux 相关问题

1.unknown option to ‘s’

sed使用变量替换,且变量含有’/'时

1
2
3
4
5
var="/etc/host"
// 习惯写法
sed -i "s/regex/$var/" file
// 可用 # ~ 替换
sed -i "s~regex~$var~" file

2.安装应用后提示 Which services should be restarted

ubuntu默认安装 needrestart 导致

1
apt purge needrestart -y

3.解决 vim 使用鼠标选择便进入 visual mode 的问题

输入 :set mouse-=a 或者直接

1
2
3
4
cat >> ~/.vimrc <<EOF
:set mouse-=a
syntax on
EOF

Git 相关问题

1.删除Git仓库中的大文件

1
2
3
4
5
6
7
8
9
10
11
12
13
# 找出大文件
git rev-list --objects --all | grep "$(git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -5 | awk '{print$1}')"

# 重写commit,删除大文件
git filter-branch --force --index-filter 'git rm -rf --cached --ignore-unmatch LARGE_FILE_NAME' --prune-empty --tag-name-filter cat -- --all

# 推送修改后的repo
git push origin master --force

# 清理和回收空间
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now

2.加速Git Clone

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 设置 Http Proxy
git config --global http.proxy socks5://127.0.0.1:7890

# 设置 SSH Proxy

vim ~/.ssh/config

# 1.Linux & macOS
cat ~/.ssh/config

Host github.com
Hostname ssh.github.com
IdentityFile ~/.ssh/id_rsa
User git
Port 443
#ProxyJump HOST
#ProxyCommand nc -v -x 127.0.0.1:7890 %h %p

# 2.Windows

Host github.com
Hostname ssh.github.com
IdentityFile ~/.ssh/id_rsa
User git
Port 443
#ProxyJump HOST
#ProxyCommand connect -S 127.0.0.1:7890 %h %p

3.Git Bash乱码问题

1
2
3
4
cat >> /etc/bash.bashrc << EOF
export LANG="zh_CN.UTF-8"
export LC_ALL="zh_CN.UTF-8"
EOF

VPS 相关问题

1.纯 IPv6 怎么访问 IPv4

1
wget -N https://gitlab.com/fscarmen/warp/-/raw/main/menu.sh && bash menu.sh 4

2.双栈网络设置 IPv4 优先

debian

1
sed -i 's/#precedence ::ffff:0:0\/96  100/precedence ::ffff:0:0\/96  100/' /etc/gai.conf

撤回ipv6优先

1
sed -i 's/precedence ::ffff:0:0\/96  100/#precedence ::ffff:0:0\/96  100/' /etc/gai.conf

3. DD 系统

DD 系统

Screen 相关

基本用法

1
2
3
4
5
6
7
8
9
10
11
# 创建
screen cmd

# 保存退出
ctrl+a d

# ls
screen -ls

# 重新连接
screen -r 编号

Windows 相关

关闭更新

1.PowerShell管理员模式执行

1
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" /v FlightSettingsMaxPauseDays /t reg_dword /d 3000 /f

2.去设置修改暂停更新时间

系统激活

Microsoft-Activation-Scripts

1
irm https://get.activated.win | iex

Windows Defender 卸载

windows-defender-remover

缺少 DLL 文件

1
sfc /scannow