sudo  passwd root
 sudo adduser jarvan1
 # 修改密码
 sudo passwd jarvan1

$ wsl -l -v
  NAME                   STATE           VERSION
* Ubuntu-18.04           Running         1
  Ubuntu-20.04           Running         2
  docker-desktop-data    Running         2
  docker-desktop         Running         2
# cmd 设置 ubuntu 默认用户为 root
$ ubuntu1804.exe config --default-user root 
tee -a /etc/sudoers <<'EOF'
# jarvan1 免密 sudo
jarvan1 ALL=(ALL) NOPASSWD:ALL
EOF
mkdir $HOME/code 
 lsb_release -a
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bk
sudo rm /etc/apt/sources.list 
sudo vim /etc/apt/sources.list 
# ubuntu20
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
sudo apt-get update 
sudo apt install net-tools  -y
sudo apt install  git  -y
sudo apt install  make  -y
sudo apt install  automake  -y
sudo apt install  cmake -y
sudo apt install  telnet  -y
sudo apt install  gcc  -y 
sudo apt install  g++ -y
sudo apt install  libtool -y
sudo apt install  unzip -y
sudo apt install git -y
git config --global user.name "dengjiawen"    # 用户名改成自己的
git config --global user.email "dengjiawenxxx@gmail.com"    # 邮箱改成自己的
git config --global credential.helper store    # 设置 Git,保存用户名和密码
git config --global core.longpaths true # 解决 Git 中 'Filename too long' 的错误
# 设置全局默认编辑器为 vim ,一开始默认是 nano
tee -a ~/.gitconfig<<'EOF'
[core]
editor=vim
EOF
#git config --global url."https://github.com.cnpmjs.org/".insteadOf "https://github.com/"
# 如果需要及时更新就把这个关闭
#git config --global --unset  url."https://github.com.cnpmjs.org/".insteadOf "https://github.com/"
# 看看成功没有
git config --list
git lfs install --skip-repo
wget https://golang.google.cn/dl/go1.18.2.linux-amd64.tar.gz -O /tmp/go1.18.2.linux-amd64.tar.gz
mkdir -p $HOME/go
tar -xvzf /tmp/go1.18.2.linux-amd64.tar.gz -C $HOME/go
mv $HOME/go/go $HOME/go/go1.18.2
tee -a $HOME/.bashrc <<'EOF'
# Go envs
export GOVERSION=go1.18.2 # Go 版本设置
export GOROOT=$HOME/go/$GOVERSION # GOROOT 设置
export GOPATH=$HOME/go # GOPATH 设置
export PATH=$GOROOT/bin:$GOPATH/bin:$PATH # 将 Go 语言自带的和通过 go install 安装的二进制文件加入到 PATH 路径中
export GO111MODULE="on" # 开启 Go moudles 特性
export GOPROXY=https://goproxy.cn,direct # 安装 Go 模块时,代理服务器设置
export GOPRIVATE=
export GOSUMDB=off # 关闭校验 Go 依赖包的哈希值
EOF

source ~/.bashrc
GOPROXY=https://goproxy.cn/,direct go install github.com/zeromicro/go-zero/tools/goctl@latest
goctl env check -i -f --verbose 
# 下载(可以去https://github.com/protocolbuffers/protobuf/releases找最新的包)
wget  https://github.com/protocolbuffers/protobuf/releases/download/v3.20.1/protoc-3.20.1-linux-x86_64.zip -O/tmp/protoc-3.20.1-linux-x86_64.zip
# 解压
unzip /tmp/protoc-3.20.1-linux-x86_64.zip -d /tmp/protoc-3.20.1-linux-x86_64
# 移动
mv protoc-3.20.1-linux-x86_64/bin/protoc $GOPATH/bin/
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
sudo apt remove openssh-server -y
sudo apt install openssh-server -y
sudo vim /etc/ssh/sshd_config
# 打开监听的端口和地址
Port 22
ListenAddress 0.0.0.0
# 支持公钥登录
PubkeyAuthentication yes
# 支持密码登录
PasswordAuthentication yes
ssh-keygen
sudo service ssh restart
vim ~/.ssh/authorized_keys 
chmod 600 ~/.ssh/authorized_keys
go install -v github.com/go-delve/delve/cmd/dlv@latest
    "go.testFlags": [
    "-v",
    "-count=1"
    ],
curl -sSL https://get.daocloud.io/docker | sudo sh
sudo service docker start
sudo systemctl enable docker
sudo apt install docker-compose -y
sudo tee -a /etc/default/docker << 'EOF'
# docker 加速镜像
DOCKER_OPTS="--registry-mirror=https://registry.docker-cn.com"
EOF

sudo service docker restart
  "registry-mirrors": [
    "https://registry.docker-cn.com"
  ]
本内容为PUDN经合法授权发布,文章内容为作者独立观点,不代表PUDN立场,未经允许不得转载。