初始化 Cheat Sheet

前言

很多时候,我们不得不在新的环境上重新配置我们的应用,在这里整了个人常用的一些配置环境用到的命令。

临时 http server

  • python

    1
    
    python3 -m http.server 8000
    
  • miniserve(支持多线程)

    1
    
    docker run -v `pwd`:/data -p 8080:8080 --rm -it m.ixdev.cn/docker.io/svenstaro/miniserve /data
    
  • node

    1
    2
    
    npm i http-server -g
    http-server -p 8080
    

APT 换源

https://linuxmirrors.cn/use/command-options/

1
2
3
4
5
6
7
8
9
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
  --source mirrors.tuna.tsinghua.edu.cn \
  --protocol http \
  --intranet false \
  --close-firewall true \
  --backup true \
  --upgrade-software false \
  --clean-cache false \
  --ignore-backup-tips

Docker 安装

https://mirrors.tuna.tsinghua.edu.cn/help/docker-ce/

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# 如果你过去安装过 docker,先删掉:
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do apt-get remove $pkg; done
# 首先安装依赖:
apt-get update -y
apt-get install ca-certificates curl gnupg -y
# 信任 Docker 的 GPG 公钥并添加仓库:
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu
/gpg
 | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  tee /etc/apt/sources.list.d/docker.list > /dev/null
# 最后安装
apt-get update -y
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y

npm 换源

1
npm config set registry https://registry.npmmirror.com

pip pypi 换源

1
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

代理

1
2
export http_proxy="http://127.0.0.1:10809" &&\
export https_proxy=$http_proxy

git 代理

1
2
git config --global http.https://github.com.proxy http://127.0.0.1:10809
git config --global https.https://github.com.proxy http://127.0.0.1:10809

git 用户信息

1
2
3
git config --global user.email "suyiiyii@gmail.com"
git config --global user.name "suyiiyii"
git config --global credential.helper store

git GPG 签名

1
2
3
4
5
git config --global --unset gpg.format
gpg --list-secret-keys --keyid-format=long
git config --global user.signingkey 228D2FDE99F82FC4
git config --global commit.gpgsign true
git config --global tag.gpgSign true

NTP 立刻同步时间

1
sudo ntpdate ntp.aliyun.com

Maven 换源

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
mkdir -p ~/.m2 && cat <<EOF > ~/.m2/settings.xml
<settings>
    <mirrors>
        <mirror>
            <id>alimaven</id>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>        
        </mirror>
    </mirrors>
</settings>
EOF

Docker 镜像

1
mkdir -p /etc/docker && echo "{  \"registry-mirrors\": [    \"https://docker.m.ixdev.cn\"  ]}" > /etc/docker/daemon.json

Rockylinux 自动选择镜像

1
echo 'fastestmirror=True' | tee -a /etc/dnf/dnf.conf

Go 换源

1
go env -w GOPROXY=https://goproxy.cn,direct

or

1
export GOPROXY=https://goproxy.cn
Licensed under CC BY-NC-SA 4.0
使用 Hugo 构建
主题 StackJimmy 设计