Skip to content

Instantly share code, notes, and snippets.

@JonasAlfredsson
Last active April 15, 2019 23:05
Show Gist options
  • Save JonasAlfredsson/6bb80ee951c61655424b9bb9f6380c75 to your computer and use it in GitHub Desktop.
Save JonasAlfredsson/6bb80ee951c61655424b9bb9f6380c75 to your computer and use it in GitHub Desktop.
Guide on how to install and uninstall Windows Subsystem for Linux on Windows 10 Server (i.e. without Microsoft Store).

Windows Subsystem for Linux on Windows 10 Server

Microsoft seems to prefer you installed WSL through their Windows Store, but the problem is that this Store does not exist on the server versions of Windows 10. This gist is therefore my notes on how to install it manually, using PowerShell.

The official guide is already quite short and informative, so this will basically just be a recap with some informative notes throughout.

Enable WSL

  1. Start PowerShell as an Administrator by opening the start menu and right clicking the program.
  2. Execute the following command:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
  1. Reboot

Install a Linux Distro

  1. Go to this link and download the Linux distro you want.
  2. Rename the downloaded .appx file to .zip and extract it.
  3. Move this extracted folder somewhere you would like on you computer (e.g. ~/WSL/Ubuntu)
  4. Run the .exe file that is located inside this folder (e.g. ~/WSL/Ubuntu/ubuntu.exe)
  5. Wait for installation to finish and then add a user and a password for the Linux environment.

⚠️ Do not move or rename this folder, as this will break the file system used by the distro.

You can now start this environment by just typing bash inside a PowerShell terminal. For additional modifications that can be made, read the info about multiple distros below.

ℹ️ For your own sanity I would recommend turning off the notification sound that the terminal makes every time you tab or backspace wrong. Uncomment the line set bell-style none in the /etc/inputrc file while inside the Ubuntu environment.

Using Multiple Linux Distros

You may extract and install all the available distributions from the official list, however, only one of them will be launched when you type bash in a PowerShell terminal. The one that is started is the (Default) environment, and it can be identified by executing:

wslconfig /l
  • Changing the default may be done through the following command (Ubuntu-18 comes from the command above)
wslconfig /s Ubuntu-18
  • When multiple environments are available, you may want to add all the distro paths to the Windows environment PATH. Here I use C:\Users\Administrator\Ubuntu as an example of one distro's path).
$userenv = [System.Environment]::GetEnvironmentVariable("Path", "User")

[System.Environment]::SetEnvironmentVariable("PATH", $userenv + "C:\Users\Administrator\Ubuntu", "User")

You may now start the Ubuntu environment by typing ubuntu.exe inside a PowerShell terminal. Adding more paths will then allow you to start each separate environment by then typing the .exe name.

Uninstall a Linux Distro

If you have not moved the folder where the distro is installed, removing it is easy.

  1. List all installed distros by running the following from a PowerShell terminal:
wslconfig /l
  1. Remove any of the above listed by running the following (Ubuntu-18 comes from the listing):
wslconfig /u Ubuntu-18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment