WSL使用

WSL官方文档

WSL常用命令

命令 说明
wslconfig /l [/running, /all] 查看已经安装的linux子系统
wslconfig /u 注销安装的子系统
wslconfit /s 将名称为name的子系统设置为默认

安装的linux子系统保存在%LocalAppData%\Packages目录下面

使用 wslconfig /u 命令注销掉,并未真正删除,store里面还是显示已安装,使用管理员身份运行下面两个powershell命令进行删除
get-appxpackage -allusers |select name, packagefullname
get-appxpackage CanonicalGroupLimited.Ubuntu20.04onWindows |remove-appxpackage

WSL下安装centos

CentWSL

已失效Rolisoft的WSL下Linux的转换方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
PS D:\workspace\github\WSL-Distribution-Switcher> git clone https://github.com/RoliSoft/WSL-Distribution-Switcher.git
Cloning into 'WSL-Distribution-Switcher'...
remote: Enumerating objects: 323, done.
remote: Total 323 (delta 0), reused 0 (delta 0), pack-reused 323
Receiving objects: 100% (323/323), 114.58 KiB | 235.00 KiB/s, done.
Resolving deltas: 100% (204/204), done.
PS D:\workspace\github\WSL-Distribution-Switcher>
PS D:\workspace\github\WSL-Distribution-Switcher> python .\get-prebuilt.py centos:8.1.1911
[*] Requesting authorization token...
[*] Fetching manifest info for centos:8.1.1911...
[*] Downloading layer sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4...
[*] Downloading layer sha256:8a29a15cefaeccf6545f7ecf11298f9672d2f0cdaf9e357a95133ac3ad3e1f07...
rootfs_centos_8.1.19... [===============> ] 30.04%[*] Rootfs archive for centos:8.1.1911 saved to rootfs_centos_8.1.1911.tar.gz.
PS D:\workspace\github\WSL-Distribution-Switcher> python .\install.py centos:8.1.1911
[*] Probing the Linux subsystem...
[!] The Linux subsystem is not installed. Please go through the standard installation procedure first.

安装失败,因为它依赖Debian子系统。即使使用Microsoft store安装了Debian子系统后,仍然执行失败,提示找不到lxrun.exe。lxrun.exe已经是废弃的应用程序。所以放弃了该种方法