开启Windows的WSL特性(需要家庭版以上的版本)

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

执行完这一步需要重启机子。

接下来要下载一个Linux镜像,这里选用的是Ubuntu20.04LTS

可以在PowerShell里面使用命令下载:

Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-2004 -OutFile Ubuntu2004.appx -UseBasicParsing

或者浏览器直接访问https://aka.ms/wslubuntu2004

Downloading distributions其他Linux镜像。

将下载下来的镜像的appx后缀改为zip后缀,然后解压出来:

Expand-Archive UbuntuXxx.zip

假设解压出来的目录是UbuntuXxx,里面有一个ubuntu2004.exe文件,只要这个文件即可开始安装。

参考:

其他

libQt5Core.so.5: cannot open shared object file

在WSL1中安装完KeePassXC之后,运行keepassxc-cli出现错误:

keepassxc-cli: error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory

根据Can’t load shared library libQt5Core.so.5,需要执行以下命令:

sudo strip --remove-section=.note.ABI-tag /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 

如果没有strip,则需要安装binutils。

18.4看这边:Ubuntu 18.4 libQt5Core.so.5: cannot open shared object file: No such file or directory

(本篇完)

2022-06-07更新

一些WSL命令

autossh

https://git.io/autossh教程说如何在wsl2里面开启openssh服务,其Github页面https://github.com/rescenic/autossh

可以看到很多配置文件在/usr目录下,而不是直接在/etc下面,Configuration files in /etc and /usr/etc为此做了一些解释

rcsshd start在wsl2下不能用,因为wsl2没有使用systemd作为系统控制框架。

执行sudo /usr/bin/ssh-keygen -A生成一个系统密钥

/usr/sbin/sshd开启sshd服务

Windows宿主上安装OpenSSH Server

# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

其他参考:

(更新完)

2022-10-22更新

可以通过wsl --update来更新wsl的基础内容,还有wsl --status可以查看wsl的状态。

(更新完)