WSL 安装Ubuntu
开启虚拟机配置
下载 wsl2 需要使用的 linux 内核
在 https://docs.microsoft.com/zh-cn/windows/wsl/wsl2-kernel 页面点击下载 linux 内核更新包,下载完点击安装
重启系统并设置WSL 2 设置为默认版本
wsl --set-default-version 2
wsl -l -v
安装配置 Linux 发行版
打开 Microsoft Store,搜索 Terminal,安装 Windows Terminal,用于后面和 WSL 子系统交互 (可能系统自带了)
微软商店搜索 Ubuntu,选择安装。(有的公司可能屏蔽了网络)
更换ubuntu的apt安装源
sudo gedit /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
sudo apt-get update
// 这里有可能报错,其实也是因为公司设置了网络拦截,用热点试试
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://mirrors.aliyun.com/ubuntu bionic-backports Release' does not have a Release file.
这个报错
解决办法
sudo gpg --keyserver keyserver.ubuntu.com --recv 5523BAEEB01FA116 //(这个公钥根据提示来写的)
sudo gpg --export --armor 5523BAEEB01FA116 | sudo apt-key add -