Win 10 以来,微软操做系统内置支持 Linux 子系统,win 10 上面自带有 Microsoft Store 应用商店,能够直接安装 Linux 子系统,可是在 Server 2016 / 2019 上,系统并无内置 Microsoft Store 应用商店,因此不能经过商店直接安装子系统。ubuntu
下面就来介绍一下,Server 2016/2019 服务器操做系统上怎样安装 Linux 子系统。windows
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
开启 Linux 子系统支持的功能。安全
也能够在图形界面下,点击“添加服务器功能” 中勾选相应功能。服务器
PS> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux Path : Online : True RestartNeeded : False
命令执行的话,显示上述信息,就表示功能已打开,无需重启。app
到微软云的下载页面 https://docs.microsoft.com/en-us/windows/wsl/install-manual 下载须要的 Linux 发行版curl
这里示例使用 ps 脚本下载远程文件,以 Ubuntu 18.04 版本为例ide
Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile ~/Ubuntu1804.appx -UseBasicParsing
或者使用 curl.exe 方式进行下载:this
curl.exe -L -o ~/ubuntu1804.appx https://aka.ms/wsl-ubuntu-1804
使用以下命令,进行操做:url
Rename-Item ~/Ubuntu1804.appx ~/Ubuntu1804.zip Expand-Archive ~/Ubuntu1804.zip ~/Ubuntu1804
解压文件后,能够看到如图的文件目录内容。操作系统
打开 ubuntu1804.exe 便可开始进入命令行安装界面:
Installing, this may take a few minutes... Please create a default UNIX user account. The username does not need to match your Windows username. For more information visit: https://aka.ms/wslusers Enter new UNIX username: YourUserName Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Installation successful! To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details. eric@WIN-SERVER2019:~$
稍等片刻,便可开始输入自定义用户名,输入密码,安全完成。