How To Enable Windows Subsystem for Linux on Windows Server 2016

This guide help you become a Windows Insider, download Windows Server, and get Linux running on the Windows Subsystem for Linux.


Windows Server 2016 (build 16215+). Right now, that means a Windows Insider's build.

Join Windows Insiders and Download Windows Server

  1. Join a Windows Insiders program:
  2. Download Windows Server 2016 - Insider Preview.
    Make sure you're logged in, images are only available to Windows Insiders.

Set up Windows Server

Now that you have a Windows Server image (.iso), install Windows Server on a physical computer or a virtual machine. I'm going to use a virtual machine on Hyper-V.

During installation, Windows Server will ask for a product key. The following keys are available for unlimited activation of Windows Server (pre-release builds only). These keys may be used throughout the pre-release cycle. Read more here.
  • Server Datacenter Core: B69WH-PRNHK-BXVK3-P9XF7-XD84W
  • Server Standard Core: V6N4W-86M3X-J77X3-JF6XW-D9PRV
When you're done, you should see something like this:

Check your build number

To find your Windows Server build number, run the following in PowerShell:
systeminfo | Select-String "^OS Name","^OS Version"
You can also confirm that your build has the Windows Subsystem for Linux by running the following in PowerShell:
Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Enable the Windows Subsystem for Linux

Enable the "Windows Subsystem for Linux" optional feature and reboot.
  1. Open PowerShell as Administrator and run:
    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
  2. Restart your computer when prompted.

Install a Linux distribution

  1. Download the appx for your favorite Linux distribution.
    Here are links directly to the apps available through the store:
    • Ubuntu
    • OpenSUSE
    • You can download the distributions to Windows Server with Invoke-WebRequest cmdlet. Here's a sample instruction to download OpenSUSE.
      Invoke-WebRequest -Uri -OutFile ~/ -UseBasicParsing
      Tip: If the download is taking a long time, turn off the progress bar by setting $ProgressPreference = 'SilentlyContinue'
  2. Unzip the file
    Expand-Archive ~/ ~/Ubuntu
    Make sure your target directory (~/Ubuntu in this example) is on your system drive. Usually this is your C: drive.
    Example: C:\Distros\Ubuntu
    The contents should look like this:

3. Run the installer, named .exe
For example: ubuntu.exefedora.exe, etc.
Troubleshooting: Installation failed with error 0x8007007e
This error occurs when your system doesn't support Linux from the store. Make sure that:
4. Create a UNIX user

The first time you install the Windows Subsystem for Linux, you will be prompted to create a UNIX username and password.
This UNIX username and password can be different from, and has no relationship to, your Windows username and password. 

5. Run distro's preferred update/upgrade.
sudo apt-get update
sudo apt-get upgrade
You're done! Go use your new Linux environment!

Windows Interoperability

Starting in Windows 10 Anniversary Update, the Windows Subsystem for Linux can invoke native Windows binaries from the Linux console and Linux binaries from a Windows console.

This interoperability functionality delivers a seamless experience between Windows and WSL.

Invoking WSL from the Windows Command Line

Linux binaries can be invoked from the Windows Command Prompt or from PowerShell. Binaries invoked in this way have the following properties:
  1. Use the same working directory as the CMD or PowerShell prompt.
  2. Run as the WSL default user.
  3. Have the same Windows administrative rights as the calling process and terminal.
C:\temp>bash -c "ls -la"
total 916
drwxrwxrwx 2 root root      0 Sep 28 08:45 .
drwxrwxrwx 2 root root      0 Sep 27 07:33 ..
-rwxrwxrwx 1 root root     14 Sep 27 14:26 foo.bat
Linux commands called in this way are handled like any other Windows application. Things such as input, piping, and file redirection work as expected.
C:\temp>bash -c "sudo apt-get update"
[sudo] password for username:
Hit:1 xenial InRelease
Get:2 xenial-security InRelease [94.5 kB]
C:\temp>bash -c "ls -la" | findstr foo
-rwxrwxrwx 1 root root     14 Sep 27 14:26 foo.bat
C:\temp>dir | bash -c "grep foo"
09/27/2016  02:26 PM                14 foo.bat
C:\temp>bash -c "ls -la" > out.txt
The WSL commands passed into bash -c are forwarded to the WSL process without modification. File paths must be specified in the WSL format and care must be taken to escape relevant characters. Example:
C:\temp>bash -c "ls -la /proc/cpuinfo"
-r--r--r-- 1 root root 0 Sep 28 11:28 /proc/cpuinfo

C:\temp>bash -c "ls -la \"/mnt/c/Program Files\"”
<- -="" c:="" contents="" files="" of="" rogram="">

Invoking Windows binaries from WSL

The Windows Subsystem for Linux can invoke Windows binaries directly from the WSL command line. Applications run this way have the following properties:
  1. Retain the working directory as the WSL command prompt except in the scenario explained below.
  2. Have the same permission rights as the bash.exe process.
  3. Run as the active Windows user.
  4. Appear in the Windows Task Manager as if directly executed from the CMD prompt.
In WSL, these executables are handled similar to native Linux executables. This means adding directories to the Linux path and piping between commands works as expected. Examples:
$ export PATH=$PATH:/mnt/c/Windows/System32
$ notepad.exe
$ ipconfig.exe | grep IPv4 | cut -d: -f2
$ ls -la | findstr.exe foo.txt
$ cmd.exe /c dir
The Windows binary must include the file extension, match the file case, and be executable. Non-executables including batch scripts and command like dir can be run with /mnt/c/Windows/System32/cmd.exe /C command. Examples:
$ /mnt/c/Windows/System32/cmd.exe /C dir
$ /mnt/c/Windows/System32/PING.EXE
Parameters are passed to the Windows binary unmodified.
As an example, the following commands will open C:\temp\foo.txt in notepad.exe:
$notepad.exe “C:\temp\foo.txt”
$notepad.exe C:\\temp\\foo.txt
Modifying files located on VolFs (files not under /mnt/) with a Windows application is not supported. By default, WSL attempts to keep the working directory of the Windows binary as the current WSL directory, but will fall back on the instance creation directory if the working directory is on VolFs.
As an example; bash.exe is initially launched from C:\temp and the current WSL directory is changed to the user’s home. When notepad.exe is called from the user’s home directory, WSL automatically reverts to C:\temp as the notepad.exe working directory:
/mnt/c/temp/$ cd ~
~$ notepad.exe foo.txt
~$ ls | grep foo.txt
~$ exit
C:\temp>dir | findstr foo.txt
09/27/2016  02:15 PM                14 foo.txt
Users may disable the ability to run Windows binaries for a single WLS session by running the following command as root:
$ echo 0 > /proc/sys/fs/binfmt_misc/WSLInterop
To reenable Windows binaries either exit all WSL sessions and re-run bash.exe or run the following command as root:
$ echo 1 > /proc/sys/fs/binfmt_misc/WSLInterop
Note that disabling interop will not persist between WSL sessions.


  1. After following step, it just executed
    Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

    and while enabling WSL it is giving following error

    Enable-WindowsOptionalFeature : Feature name Microsoft-Windows-Subsystem-Linux is unknown.
    At line:1 char:1
    + Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows- ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Enable-WindowsOptionalFeature], COMException
    + FullyQualifiedErrorId : Microsoft.Dism.Commands.EnableWindowsOptionalFeatureCommand

    1. Share the output from the following command:

      systeminfo | Select-String "^OS Name","^OS Version"
      Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

    2. WSL is only available starting with Windows Server 2016 (release 1803), Windows Server 2019 (release 1709) and later, and for Windows 10 x64 systems: Version 1903 or higher, with Build 18362 or higher. For ARM64 systems: Version 2004 or higher, with Build 19041 or higher. Windows 10 Builds lower than 18362 do not support WSL 2. Use the Windows Update Assistant to update your version of Windows.


Powered by Blogger.