1. 启用 WSL 功能
以管理员身份打开 PowerShell
,输入如下命令(然后根据提示重启电脑):
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
2. 下载和安装 Linux 系统
下载地址: Ubuntu 18.04 (推荐迅雷)
双击 .appx
文件进行安装,按照提示设置用户名和密码,然后就安装成功了
备份官方源,重写为国内 ubuntu 源:
# 备份
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
# 重写
sudo vi /etc/apt/sources.list
/etc/apt/sources.list
的内容:
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
更新系统包和软件: sudo apt update && sudo apt upgrade
其他系统下载参考 https://docs.microsoft.com/en-us/windows/wsl/install-manual
3. 设置
- 修改终端字体:右键 -> 属性 -> 字体,选择
Hack
:
-
进入 wsl: 在开始菜单将 ubuntu 拖到面板上,点击图标就可以进入了。或者固定在任务栏