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 命令了;