WSL2 安装教程
WSL 可以在 Windows 下运行 Linux ,而且性能高,启动速度快,基本可以满足日常需求。
安装 WSL 1
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart重启。
升级到 WSL 2
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart重启。
下载更新包
设置版本
wsl --set-default-version 2在 Microsoft Store 安装 Linux 版本。
推荐 Ubuntu ,功能齐全。
初始化
在
Powershell或Windows Terminal中输入Debian,会提示配置用户名和密码。配置 root 用户
运行
debian config --default-user root,即可默认启用 root 账户。设置国内源
使用以下内容覆盖
/etc/apt/sources.list。可以使用vim等命令,具体百度。deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse设置默认 Linux
wslconfig /list wslconfig /setdefault Ubuntu