Windows Subsystem for Linux (WSL) is a complete operating system that you can enable on your Windows Server and also on Windows 10 devices. Previously, “WSL” was originally known as the “Bash on Windows” feature and it allowed users to use Ubuntu bash commands in Windows PowerShell.
– More on WSL, see https://techdirectarchive.com/2020/05/05/what-is-windows-subsystem-for-linux-wsl/
– WSL has been available for Windows 10 since 2017, and starting from Server 2016 version 1803 (released April 30, 2018), WSL can now be installed on WSL.
On how to setup a Windows Server 2019 see https://techdirectarchive.com/2020/03/18/how-to-install-windows-server-2019-in-virtualbox/
– On how to perform Post OS Installation – Configure Windows Server 2019 Properties, see https://techdirectarchive.com/2020/03/19/post-os-installation-configure-windows-server-2019-properties/
How does Windows Subsystem for Linux (WSL) work?
WSL translates the Linux system calls returned by the process to the Windows kernel calls while a Linux Distro sits on top. It is thus eliminating the need for the Linux kernel in the process. So basically, it is Linux inside Windows. Furthermore, there is no emulation involved whatsoever.
On how this is done on Windows 10, see https://techdirectarchive.com/2020/04/26/virtualbox-how-to-install-the-windows-subsystem-for-linux-wsl-on-windows-10/
In this Windows Server, below are the following ways to install the Windows Subsystem for Linux.
Server Manager (Windows Features). Via PowerShell.
Via Server Manager. WSL can be installed from the Server Manager. To do this, bring up the Server Manager as shown below and Click on Manage
Next, select Add roles or features,
– Select Role-based or feature-based installation as shown below
– Click on Next
– Select your local server
Note: If you have many servers in the pool, ensure the right server is selected, and then click on next.
– Click Next, this will open the “Select Server roles” page.
Note: WSL is not a role, therefore we have no business with this page, skip it by click on Next :)
– On the Select features page, select Windows Subsystem for Linux as shown below and, then click on Next.
– Finally, on the confirmation page, click on Install.
Note: You will have to restart. In order to ensure Windows does this automatically, select “Restart the destination server automatically if required”.
The installation will run and you can now close the window if you wish.
After installation is complete, the server will be restarted automatically and WSL will be available. This reboot is required in order to ensure that WSL can initiate a trusted execution environment.
– Next, open a command prompt and enter on the terminal “WSL” and the following information will be prompted “WSL was working but no Linux distributions were installed”.
It instructed me to go to https://aka.ms/wslstore as shown below. This message seems to be an error as this URL does not work.
Download a Linux Distro: To get this work, I was able to enter https://aka.ms/wsl-ubuntu-1604 on my Web browser and download Ubuntu for WSL as shown below.
For other distros, see the links below. You do not need administrative privileges to install the distribution because this takes place in the user's profile. The download links are:
– Ubuntu 18.04: https://aka.ms/wsl-ubuntu-1804
– Ubuntu 18.04 ARM: https://aka.ms/wsl-ubuntu-1804-arm
– Ubuntu 16.04: https://aka.ms/wsl-ubuntu-1604
– Debian GNU/Linux: https://aka.ms/wsl-debian-gnulinux
– Kali Linux: https://aka.ms/wsl-kali-linux
– OpenSUSE: https://aka.ms/wsl-opensuse-42
– SLES: https://aka.ms/wsl-sles-12
Next, Extract the downloaded distro as shown below
Open up the extracted folder and double click ubuntu as shown below.
This will install Ubuntu on your device as shown below
This will take few minutes to install and you will be prompted to enter a user and set the user’s password as shown below.
Now that the installation and configuration is complete, you can now start by entering "WSL" on the command prompt (terminal) and use the WSL bash shell to perform various functions
That is all that needs to be done to have WSL running on your server.
Via PowerShell: With these steps, the above steps can be ignored.
Step 1: Before you can run Linux distros on Windows, you must enable the “Windows Subsystem for Linux” optional feature and reboot.
– Open PowerShell as Administrator and run the syntax (commands) below.
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Restart your server when prompted. This reboot is required in order to ensure that WSL can initiate a trusted execution environment.
Step 2: Install the Linux Distro of your choice.
You will have to download a Linux distro. This steps has been discussed in the steps above.
Download the inux distro as discussed above.
– To extract the distro package, you can use PowerShell as shown below you do not have 7Zip or others installed on your Server.
Rename-Item .\Ubuntu.appx .\Ubuntu.zip Expand-Archive .\Ubuntu.zip .\Ubuntu
Because, I have demonstrated this above, I will have to stop here. for more steps on how this can be done, see https://docs.microsoft.com/en-us/windows/wsl/install-on-server
If you need additional information on the following steps explained above, kindly leave a comment below.