Getting Windows Subsystem for Linux

This is a quick intro to Windows Subsystem (WSL) for Linux and how to get it installed.

[This is a wiki post, feel free to add information, or new sections about WSL with the edit button at the end of this post]

Table of Contents

Enable and Install

Search for: Turn Windows Features on and off (you can press the windows key and search for 'features')
fig1

image

Or You can enable the feature from powershell

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

You will likely need to reboot at this point as well.

Next install a WSL distro. Currently there is only Ubuntu, OpenSUSE Leap 42, and SUSE Linux Enterprise Server 12. Fedora is scheduled to be included in the near future.

You can install these from the Windows Store by searching for “WSL”

fig2

You can also install a distro from the command line, though it is a little more involved. Instructions for this method can be found here https://docs.microsoft.com/en-us/windows/wsl/install-on-server

Available Distributions

Currently available distros:

  • Ubuntu
  • OpenSUSE
  • OpenSUSE professional
  • Debian
  • Kali Linux

Distros in the works:

  • Fedora

Use

You can run the system from the windows start menu (in my case, searching for ubuntu), or via running bash from the command line in cmd or powershell to invoke the default distro. wsl will do the same, or you can specity the distro you want to start, e.g. ubuntu

You’ll be asked to create a user and password when you first initialise the system. once done, welcome to your new Linux distro on Windows.

Most things works. With newer Windows releases you will have access to better integration.

I think the main limitation right now is the lack of X/Wayland support for example. Though this is initially designed for accessing a Linux core system for the power it can provide.

You can do some cool things with it like calling Linux commands from Windows

Use Cases for WSL

C Development on Windows with WSL

To setup a C dev environment on Windows with WSL:

sudo apt install build-essential gdbserver cmake -y

You can integrate it with Visual Studio, too.

sudo apt install openssh-server -y && sudo ssh-keygen -A

  • Start the ssh service and open Visual Studio

  • Tools > Options > Cross Platform > Connection Manager

  • Add a new connection

Host name: Should default to localhost
Port: Default is 22 (change your /etc/ssh/sshd_config to allow your WSL username to connect)
Auth: Password
Password: WSL password

Create a New Project
Visual C++ > Cross Platform > Linux

You can use the Remote GDB Debugger option.

Linux GUI on WSL

At the moment a native GUI isnt supported in the traditional sense. You can run a GUI on a WSL distro through through the use of VNC.

See @wr250’s post on VNC in WSL in the section Below.

Tidbits

Disable annoying Windows noise whenever you backspace or can't autocomplete anything.
sudo vim /etc/inputrc

Uncomment

# set bell-style none

Restart shell.

More Information

Contributors

@Eden, @SudoSaibot, @wr250, @anon79053375

Talk page

Feel free to discuss edits, changes, or other contributions to this topic here: Topic Talk Page

top

8 Likes

LXDE (Graphical UI) works in WSL.

You need to install WSL as above, then after entering bash, install tightvncserver.
Instructions for ubuntu:

sudo apt-get install tightvncserver 
sudo apt-get install lxde

While that’s working goto www.tightvnc.com, and download the appropriate windows version of tightvnc (you need the viewer only).

Install the package and customize to get the viewer only; unless you want the server as well.

Go back to your bash prompt and when its finished installing the above , then run “vncserver” (no quotes).

Follow the one time password prompts and it will fork into the background. check this with ps ax |grep vnc, if Xvncserver or similar is running then its running.

Back to windows and launch the tightvnc viewer

Connect to localhost:5901 if that fails try 5900

It should prompt for the password you made and put you on a lxde desktop.

1 Like