Win10安装与配置Linux子系统WSL

安装WSL

第一步:进入控制面板打开程序与功能页面,选择启用或关闭Windows功能

控制面板

第二步:开启“适用于Linux的的Windows子系统”

这个过程需要联网进行更新安装一些组件,然后重启系统才能进入下一步。
打开“适用于Linux的Windows子系统”

第三步:重启完后进入微软的应用商店应用,搜索Linux,选择你想要使用的发行版并安装

我选择的是Ubuntu 20.04 LTS,Ubuntu的长期支持版本。稳定好用。
在应用商店程序搜索Linux
安装完成后点击图标打开进行初始配置,如用户名和密码设置即可开始使用了。安装后运行样式

配置WSL

WSL安装后需要改一下软件源来提高下载安装软件包的速度。默认的源访问非常慢,可以使用国内的一些镜像站点来提高速度,比如使用清华源,腾讯云的源,阿里云的源或者网易的源等等此处使用清华的源。
访问清华源的网址:清华源中关于Ubuntu的帮助页面
打开WSL输入sudo apt edit-sources即可修改源,第一次进入会提示选择一个文本编辑器比如nano或者vim默认是nano,直接enter就行。可以删除文件中所有的源或者注释掉,注释使用#即可。
然后将下面这段代码复制进去即可。
保存并退出,nano的操作时ctrl x然后按一下enter即可

# 默认注释了源码镜像以提高 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

猜你喜欢

转载自blog.csdn.net/sinat_24866629/article/details/108904800