• Home
  • About
    • Moon photo

      Moon

      a development programmer, backend, Java.

    • Learn More
    • Github
  • Posts
    • All Posts
    • All Tags
  • Projects

WSL2 install

03 Dec 2021

Reading time ~1 minute

WSL2 和 docker 安装

WSL2 安装

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Restart-Computer

更新设置版本

# 更新前检查 Windows 10 LTSC 2021 是否安装 KB5020030
wsl --update
wsl --set-default-version 2

WSL2 配置并启用 systemd

echo -e "[boot]\nsystemd=true" | sudo tee -a /etc/wsl.conf
# 检查 systemd 是否启用,输出 init 则说明 systemd 未启用,需要检查是否安装 KB5020030 更新
ps --no-headers -o comm 1
# https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/
sudo sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
sudo sed -i 's/security.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
sudo apt update
sudo apt install -fy net-tools
sudo apt install -fy libreoffice
fc-list :lang=zh-cn
sudo locale-gen zh_CN.UTF-8

安装 docker

# curl -fsSL https://get.docker.com -o get-docker.sh && sudo sh get-docker.sh
sudo apt install -fy docker.io
# DOCKER_OPTS="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock"
# sudo vim /etc/default/docker
sudo systemctl enable docker
sudo gpasswd -a $USER docker
newgrp docker

root 远程登录

# 修改root密码
sudo passwd root
# 测试root登录
su root
# Port 22
# ListenAddress 0.0.0.0
# PasswordAuthentication yes
sudo vim /etc/ssh/sshd_config
sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
sudo apt autoremove openssh-server
sudo apt install -fy openssh-server
sudo service ssh --full-restart
sudo ufw allow ssh

Recommended Apps

  • 7-Zip
  • bilibili(UWP)
  • Docker(WSL)
  • Everything
  • Fiddler Classic
  • Git
  • 火绒
  • JDK8
  • IDEA
  • Lantern
  • Edge
  • NeatDownloadManager
  • Postman
  • Ubuntu20.04(UWP)
  • VSCode
  • WPS(UWP)
  • VLC
  • OBS
  • XMind8
  • draw.io(UWP)
  • nodejs

参考

https://monkeywie.cn/2021/09/26/wsl2-gui-idea-config/



LinuxWSL2Windows 10wslg Share Tweet +1