腾讯云主机初始化
由于腾讯云主机初始账户为ubuntu
,所以建议改为root
,方便以后敲命令
1
2
3
4
5
6
7
8
9
10
11
12
| sudo passwd root
# 输入密码
sudo vim /etc/ssh/sshd_config
# 修改配置
PermitRootLogin yes
# 重启ssh
sudo service ssh restart
# 重新登录服务器
|
修改 WSL Ubuntu 18.04 默认源为阿里云镜像
1
2
3
4
5
6
| vim /etc/apt/sources.list
:%s/security.ubuntu/mirrors.aliyun/g
:%s/archive.ubuntu/mirrors.aliyun/g
apt update
|
kali linux 国内源
1
2
3
4
5
| deb http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib
deb-src http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib
apt update
apt-get install xrdp fcitx fcitx-googlepinyin
|
Ubuntu 静态 IP
vim /etc/netplan/50-cloud-init.yaml
1
2
3
4
5
6
7
8
9
10
| network:
ethernets:
eth0:
addresses:
- 192.168.31.100/24
gateway4: 192.168.31.1
nameservers:
addresses:
- 192.168.31.1
version: 2
|
netplan apply
,启用配置
Linux scp 命令
scp
是secure copy
的缩写,scp是Linux系统下基于ssh登陆进行安全的远程文件拷贝命令
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| 从本地复制到远程
# 拷贝文件
scp /home/test/test.txt root@192.168.0.2:/home/test/
# 拷贝目录
scp -r /home/test/ root@192.168.0.2:/home/test/
从远程复制到本地
# 拷贝文件
scp root@192.168.0.2:/home/test/ /home/test/test.txt
# 拷贝目录
scp -r root@192.168.0.2:/home/test/ /home/test/
|
zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| apt install git zsh lrzsz screenfetch -y
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# 国内镜像
sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"
cd ~/.oh-my-zsh/custom/plugins
git clone https://github.com.cnpmjs.org/zsh-users/zsh-autosuggestions.git
git clone https://github.com.cnpmjs.org/zsh-users/zsh-syntax-highlighting.git
git clone https://github.com.cnpmjs.org/wting/autojump.git
# python 环境变量
ln -s /usr/bin/python3 /usr/bin/python
cd autojump && python install.py
|
vim ~/.zshrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| ZSH_DISABLE_COMPFIX="true"
DISABLE_AUTO_UPDATE="true"
export PATH="$PATH:/Users/hfy/Library/Android/sdk/platform-tools:/Users/hfy/Library/Android/sdk/tools"
plugins=(
git
zsh-autosuggestions
zsh-syntax-highlighting
)
source $ZSH/oh-my-zsh.sh
[[ -s /root/.autojump/etc/profile.d/autojump.sh ]] && source /root/.autojump/etc/profile.d/autojump.sh
autoload -U compinit && compinit -u
export PATH=/usr/local/php/bin:$PATH
export PATH=/usr/local/mysql/bin:$PATH
|
source ~/.zshrc
bat
1
2
| wget https://github.com/sharkdp/bat/releases/download/v0.12.1/bat_0.12.1_amd64.deb
dpkg -i bat_0.12.1_amd64.deb
|
lrsz
Xshell 上传文件到 Linux 和下载文件到 Windows
1
2
3
4
5
6
7
8
| apt install lrzsz -y
# Windows 传文件 到 Linux
rz
# Linux 传文件到 Windows
# 文件夹需要 tar -czvf 打包
sz [file]
|
Python
1
| pip install sandman2 -i http://mirrors.tencentyun.com/pypi/simple --trusted-host mirrors.tencentyun.com
|
Gitea
1
2
3
4
5
6
7
8
9
10
11
12
| wget -O gitea https://dl.gitea.io/gitea/1.11.0/gitea-1.11.0-linux-amd64
chmod +x gitea
./gitea web -p 9096
wget https://raw.githubusercontent.com/go-gitea/gitea/master/contrib/systemd/gitea.service
vim gitea.service
cp gitea.service /etc/systemd/system/gitea.service
systemctl enable gitea
systemctl start gitea
|
rm 回收站
1
2
3
4
| mkdir -p ~/.Trash
vi ~/.bashrc
source ~/.bashrc
|
~/.bashrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| alias rm=trash
alias rl='ls ~/.Trash'
alias ur=undelfile
undelfile()
{
mv -i ~/.Trash/$@ ./
}
trash()
{
mv $@ ~/.Trash/
}
cleartrash()
{
read -p "Clear trash?[n]" confirm
[ $confirm == 'y' ] || [ $confirm == 'Y' ] && /usr/bin/rm -rf ~/.Trash/*
}
|
使用
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| # 删除一个文件夹,helloworld下面的文件均被移到回收站中
rm helloworld
# 删除一个文件
rm abc.txt
# 撤销abc.txt
ur abc.txt
# 撤销helloworld文件夹
ur helloworld
# 列出回收站
rl
# 清空回收站
cleartrash
|
防火墙
1
2
3
4
| ufw status
ufw disable
ufw enable
ufw allow 2222
|
apache 配置文件服务器
1
2
3
4
5
6
| <Directory "/www/wwwroot/static.cloud.laijw.com">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
|
Centos Anaconda
1
2
3
| wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.3.1-Linux-x86_64.sh
chmod u+x Anaconda3-5.3.1-Linux-x86_64.sh
./Anaconda3-5.3.1-Linux-x86_64.sh
|
zsh:command not find:conda
1
2
3
| vim ~/.zshrc
export PATH=/root/anaconda3/bin:$PATH
|
中国镜像
1
2
3
4
5
6
7
8
| conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
# 搜索时显示通道地址
conda config --set show_channel_urls yes
# 清除索引缓存
conda clean -i
|
~/.condarc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| channels:
- defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
|
Kali
中文乱码解决方案
1
2
3
4
5
6
7
8
9
10
11
12
| vim /etc/apt/sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling main contrib non-free
apt-get clean && apt-get update -y
sudo apt-get install ttf-wqy-microhei ttf-wqy-zenhei xfonts-intl-chinese
dpkg-reconfigure locales
reboot
|
node.js
1
2
3
4
5
6
| curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
apt-get install -y nodejs
npm config set registry https://registry.npm.taobao.org
npm install -g yarn
yarn config set registry https://registry.npm.taobao.org
|
sqlite
关于The database disk image is malformed
问题的解决
一般来说,用sqlite3执行以下命令就修复了。
1
2
3
| sqlite3 old.db .dump > newsfeed.sql
sqlite3 new.db < newsfeed.sql
|
但是我尝试了好几次,修复之后的数据库都是0KB的。
几经周折我发现,损坏的数据库dump成sql之后,最后一行变成了ROLLBACK;
好家伙,全给我回滚了啊。
把ROLLBACK;
改成COMMIT;
再执行sqlite3 new.db < newsfeed.sql
更新 Gitea webhook
1
2
3
| sqlite3 gitea.db "select url from webhook"
sqlite3 gitea.db "UPDATE webhook SET url = 'https://code.laijw.com/gitea'"
sqlite3 gitea.db "UPDATE hook_task SET url = 'https://code.laijw.com/gitea'"
|
curl 缺失 libssl.so.1.0.0
curl: error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory
原因是因为安装了 Anaconda 环境的原因
1
2
3
4
5
| find / -name 'libssl.so*'
l|grep 'libssl.so*'
ln -s /root/anaconda3/pkgs/openssl-1.0.2p-h14c3975_0/lib/libssl.so.1.0.0 /usr/lib64/libssl.so.1.0.0
ln -s /root/anaconda3/pkgs/openssl-1.0.2p-h14c3975_0/lib/libcrypto.so.1.0.0 /usr/lib64/libcrypto.so.1.0.0
|
ruby 环境搭建
1
2
3
4
5
6
7
8
9
| apt-get install -y ruby-full ruby-bundler
gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
gem sources -l
gem install jekyll
jekyll new jekyll-blog
cd jekyll-blog
bundle install
bundle exec jekyll serve --host=0.0.0.0 --port 8080
|
openssh 长时间断线问题
1
2
3
4
5
| cd ~
cd.>config
notepad config
ServerAliveInterval 60
|
win10 wsl1 转换为 wsl2
1
2
3
4
5
6
7
| # 启用“虚拟机平台”可选组件
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
# 重启电脑
wsl -l -v
wsl --set-default-version 2
wsl --set-version Ubuntu-18.04 2
|
Windows Terminal 配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| {
"guid": "{1c4de342-38b7-51cf-b940-2309a097f589}",
"hidden": false,
"name": "bash",
"commandline": "C:\\Program Files\\Git\\bin\\bash.exe --login -i",
"icon": "C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico",
"startingDirectory": "%USERPROFILE%"
},
{
"guid": "{9bd921f5-cbd3-4e51-a852-547096e50055}",
"hidden": false,
"name": "babun",
"commandline": "C:\\Users\\LJW\\.babun\\cygwin\\bin\\zsh.exe --login -i",
"icon": "C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico",
"startingDirectory": "%USERPROFILE%"
},
|