WSL2使用指南
WSL2简介及安装
安装WSL2支持的Linux发行版
进入 Microsoft Store 搜索关键词 wsl
,选择要安装的Linux发行版,推荐安装 Ubuntu。
Ubuntu系统配置
替换 APT 软件源
备份原有源文件:
bash
# 备份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
1
2
2
执行 sudo nano /etc/apt/sources.list
修改 sources.list
文件,更改为阿里源:
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
更新软件源并升级:
bash
# 更新
sudo apt update
# 升级
sudo apt upgrade
1
2
3
4
2
3
4
配置中文环境
安装中文语言包:
bash
sudo apt install language-pack-zh-hans language-pack-zh-hans-base
1
运行语言支持检查:
bash
sudo apt install $(check-language-support)
1
执行 sudo nano /etc/default/locale
修改配置文件为如下内容:
toml
LANG=zh_CN.UTF-8
LANGUAGE=zh_CN:zh
LC_NUMERIC=zh_CN
LC_TIME=zh_CN
LC_MONETARY=zh_CN
LC_PAPER=zh_CN
LC_NAME=zh_CN
LC_ADDRESS=zh_CN
LC_TELEPHONE=zh_CN
LC_MEASUREMENT=zh_CN
LC_IDENTIFICATION=zh_CN
LC_ALL=zh_CN.UTF-8
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
执行 sudo nano /etc/environment
在环境配置文件追加以下内容:
toml
LANG=zh_CN.UTF-8
LANGUAGE=zh_CN:zh
LC_NUMERIC=zh_CN
LC_TIME=zh_CN
LC_MONETARY=zh_CN
LC_PAPER=zh_CN
LC_NAME=zh_CN
LC_ADDRESS=zh_CN
LC_TELEPHONE=zh_CN
LC_MEASUREMENT=zh_CN
LC_IDENTIFICATION=zh_CN
LC_ALL=zh_CN.UTF-8
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
重启 WSL2 服务:
打开 任务管理器 -> 服务 -> LxssManager
,右键菜单选择 重新启动
。
评论区留言准则:
1. 本评论区禁止传播封建迷信、吸烟酗酒、低俗色情、赌博诈骗等任何违法违规内容。
2. 当他人以不正当方式诱导打赏、私下交易,请谨慎判断,以防人身财产损失。
3. 请勿轻信各类招聘征婚、代练代抽、私下交易、购买礼包码、游戏币等广告信息,谨防网络诈骗。