How to run Linux on Windows Server 2019 with WSL
Questions: How would I be able to empower the Windows Subsystem for Linux (WSL). How would I use Linux on Windows Server 2019?. This guide will tell you the best way to empower Windows Subsystem for Linux (WSL) include on Windows server 2019 and run a Linux Server, for example, Ubuntu inside Windows Server.
The Windows Subsystem for Linux allows you to run a GNU/Linux environment that incorporates most Linux command-line tools, utilities, and applications legitimately on your Windows framework with no adjustment or overhead on the host system.
One pre-essential is as of now introduced Windows Server 2019. we have a guide on the installation of Windows Server 2019.
Stage 1: Enable Windows Subsystem for Linux (WSL) feature on Windows
Before you can install any Linux appropriation for WSL, you should ensure that the “Windows Subsystem for Linux” feature is enabled:
Open PowerShell as Administrator and run the following command to enable Windows Subsystem for Linux (WSL) feature on Windows.
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Agree to restart your computer when prompted.
You can do the same from the Server Graphical Interfaces Server Manager>Add roles and features>Select features
Stage 2: Install your Linux Distribution of Choice
There are various ways by which you can introduce WSL Linux distros by means of the Microsoft Store. In this guide, we will use download and introduce one from the Command-Line.
Launch PowerShell and download the distro with the use of the Invoke-WebRequest cmdlet or using curl.exe. Here’s a sample instruction to download Ubuntu 18.04.
curl.exe -L -o ubuntu-1804.appx https://aka.ms/wsl-ubuntu-1804
After the download, extract and install a Linux distro.
Rename-Item ubuntu-1804.appx ubuntu-1804.zip
Expand-Archive ubuntu-1804.zip ubuntu1804
Change your working directory to ubuntu1804 and run the installer to finish your distro installation.
The installer will prompt you to provide the username and password for the UNIX user to be created.
The Sudo command can be used for privileged operations.
sudo apt update && sudo apt upgrade
sudo apt install ansible
Add your distro path to the Windows environment PATH using Powershell:
$userenv = [System.Environment]::GetEnvironmentVariable(“Path”, “User”)
[System.Environment]::SetEnvironmentVariable(“PATH”, $userenv + “C:\Users\Administrator\ubuntu1804”, “User”)
This will enable you to launch your distro from any path by typing the .exe launcher. For example using ubuntu1804.exe.
Note that this will require closing and relaunching PowerShell.