ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
[TOC] > [参考](https://zhuanlan.zhihu.com/p/348813745) ## 启用适用于 Linux 的 Windows 子系统 在 powerShell 中打开 ``` dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart ``` ## 检查运行 WSL 2 的要求 若要更新到 WSL 2,需要运行 Windows 10。 * 对于 x64 系统:**版本 1903**或更高版本,采用**内部版本 18362**或更高版本。 * 对于 ARM64 系统:**版本 2004**或更高版本,采用**内部版本 19041**或更高版本。 * 低于 18362 的版本不支持 WSL 2。 使用[Windows Update 助手](https://link.zhihu.com/?target=https%3A//www.microsoft.com/software-download/windows10)更新 Windows 版本。 可通过 cmd 的 `ver` 命令 ``` > ver Microsoft Windows [版本 10.0.19044.1645 ``` **重新启动** 计算机 ## 启用虚拟机功能 ``` dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart ``` ## 下载 Linux 内核更新包 [WSL2 Linux 内核更新包-wsl_update_x64.msi](https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi) ## 将 WSL2 设为默认版本 ``` wsl --set-default-version 2 ``` ## 安装子系统 ``` > wsl -l -o > wsl --install -d Ubuntu-18.04 ``` 在开始栏点击 Ubuntu,创建用户 ## 设置为 WSL2 去执行 ``` //通过管理员 Powershell 执行以下命令查询分配的版本 wsl -l -v wsl --set-version <发行版全称> 2 ``` ## 换国内镜像源 ``` sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak vi /etc/apt/sources.list // 写入一下内容 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 sudo apt-get -y update && sudo apt-get -y upgrade ``` ## 安装 界面 只有 win 11 https://docs.microsoft.com/zh-cn/windows/wsl/tutorials/gui-apps