One of the most top feature in the next build of Windows Server (RS3) will be the Windows Subsystem for Linux, a way to use some Linux distros inside Windows in order to extend the possibility to do many things with only one operating system.
WSL was already present in actual build of Windows 10 but now the feature is evolved in a new mode. Today we will see how to enable and use the various distros.
First of all, download and install Windows Server RS3 – physical or virtual as you want. As you know, the RS3 will introduce a new cycle for Windows Server where a new build will be released every 6 months but only in Server Core edition and this means no UI.
To configure some settings, you can use the sconfig tool – figure 1 – and if you have a lab with Active Directory could be better join the machine into it just to manage the machine via Remote PowerShell.
Figure 1 – sconfig
If you are using the preview build, use these keys to enable the product:
- Server Datacenter: B69WH-PRNHK-BXVK3-P9XF7-XD84W
- Server Standard: V6N4W-86M3X-J77X3-JF6XW-D9PRV
Enable Role and Distro
Use this command to enable new Windows Subsystem for Linux: Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
After the restart, you will be able to download and install the distro. This is a faster script to simplify the task:
Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1604 -OutFile Ubuntu.zip -UseBasicParsing Expand-Archive .\Ubuntu.zip C:\Linux\Ubuntu Remove-Item Ubuntu.zip
In this moment, you can install three different distros:
- Ubuntu: https://aka.ms/wsl-ubuntu-1604
- OpenSUSE: https://aka.ms/wsl-opensuse-42
- SLES: https://aka.ms/wsl-sles-12
Coming soon, CentOS and Fedora.
Run the execute of your distro (ubuntu.exe if you are using Ubuntu) and wait few minutes for the first setup. At the end of task, you will be prompted to create a UNIX username and password. Remember that is no relation between Windows and Linux accounts.
Run apt-get update and apt-get upgrade to align the distro with the last updates et voilà, you are ready to use your Linux machine – figure 2.
Figure 2 – Ubuntu Ready to Use
Interaction Between Windows and Linux
A part the isolated bubble, there’s the possibility to use run Linux command inside Windows and viceversa. For example, in Windows you can run the command bash -c “ls -la”
Figure 3 – Run Bash from Windows
Or, in Linux, you can run the command: cmd.exe /c dir
Figure 4 – Run Prompt from Linux
Keep in mind that the Windows execute must be called with the extension (cmd.exe), not only with the program name (cmd). Another important point is that the executable cannot be execute from anywhere until the path is registered into the variable (but this is like Windows). To register a Path variable, you can use this command: export PATH=$PATH:/mnt/c/Windows/System32
After this, you can call the executable from any part of disk, as showed in figure 5.
Figure 5 – Notepad from Linux
From the permission side, the binary is executed with the same permission of bash.exe – figure 6.
Figure 6 – Task Manager
The Windows Subsystem for Linux integration a great point to start for Windows Server because change the approach about interaction between Windows and Linux. In same scenarios, like Docker and Web, the possibility to have both OS helps IT Administrator to reduce the effort and optimize the hardware resource.
In this moment WSL cannot provide all the functionality but Microsoft tends to point out, that it has the potential to become much more powerful and interesting than it already is.
For who want learn more about WSL, I suggest this article from Product Team that explain the integration between Windows and Linux: https://blogs.msdn.microsoft.com/wsl/2016/10/19/windows-and-ubuntu-interoperability/