win10添加 Microsoft store中自带的Ubuntu18.04
在win10的系统有支持linux内核的工具wsl
在任务栏总搜索“功能”
勾选适用于Linux的windows子系统;等待升级。
然后在Microsoft store中查找Ubuntu
我这里使用的是18.04,所以主要说下这个版本的。
下载好之后,等待安装、重启电脑、win键中会有一个Ubuntu的图标以后使用时便可以点击这里进去
附加:升级wsl、启用systemctl(该版本默认未启用)、安装docker
系统设置中找到"更新与安全"--->将版本升级至最新版(可能需要30 - 60min)
之后参考官方的文档来操作:
https://docs.microsoft.com/en-us/windows/wsl/wsl2-install
https://discourse.ubuntu.com/t/using-snapd-in-wsl2/12113
运行以上两行命令(切记使用管理员身份)
这里就是进行了两项设置:make sure that both the Virtual Machine Platform and Windows Subsystem for Linux optional components are installed.
大概就是启用了了Virtual Machine Platform and Windows Subsystem 这两个
然后将wsl的版本升级到2.0版本,还是在PowerShell中或者cmd中(管理员身份)
<Distro> 这个参数使用 wsl -l来查看;例如:
启用systemctl
https://discourse.ubuntu.com/t/using-snapd-in-wsl2/12113
进入到Ubuntu系统中,运行一下两行命令:
sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target
exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME
具体含义可以参考官网的文档!
现在就可以是用systemctl 命令了;