Since the Windows 10 Fall Creators Update from 2017, the Windows Subsystem for Linux (WSL) is a fully supported Windows feature. In case you don’t already know about that feature: WSL is a compatibility layer which allows running 64 bit Linux binary executables (in ELF format) natively on Windows 10 and Windows Server 2019 in a console window. It uses much fewer resources than a fully virtualized machine. Since all Windows drives are, by default, mounted with their drive letters under
/mnt/ it also allows users to use Windows apps and Linux tools on the same set of files. By pressing Shift while right-clicking on a directory in the explorer, you will even see a new context menu entry named “Open Linux shell here“.
To enable WSL you need to enable the corresponding Windows Feature: press
WIN+R, enter “optionalfeatures“, press
Enter, enable the “Windows Subsystem for Linux” in the dialog and reboot the machine. After that, you can choose from and install one of the Linux distributions available in the Microsoft Store: Ubuntu, Ubuntu 18.04 LTS, Debian, SUSE Linux Enterprise Server 12, openSUSE Leap 42, Kali Linux, or just search for “Linux” on the Microsoft Store. At first start, you have to choose a username and a password and you are good to go. You can read more about the installation process in this Microsoft Guide.
Microsoft sees the Windows Subsystem for Linux primarily as a tool for developers, especially web developers. For example, the
gcc compiler and the
build-essential package is installed by default. Let’s see, if we can go beyond that stated purpose and run Linux GUI applications on Windows without the overhead of a virtual machine. And indeed that’s possible.
The first step is to install an X Server. There are already a lot of X Server apps for windows you can choose from. Maybe the most popular and up-to-date software is the VcXsrv Windows X Server. Unfortunately, that didn’t work. Next, I tried the Xming X Server for Windows, and even though the free version of this software hasn’t been updated for almost three years, it worked perfectly.
After installation of an X Server, we have to tell the Linux apps where to send the video data. To make that information persistent, you can create or edit the file
.bash_profile in your home directory
and add the line
Next, we can install Firefox the usual way. For this test, I have installed Debian 9.7 as the WSL distribution, so the standard packages provide Firefox ESR:
If all worked well and the X Server is running, the Firefox app window should now open on your Windows desktop.
There is one caveat: there is no graphics acceleration available, so the video output might be a bit slow sometimes.
Small excursion: Securing the environment
After the installation of Firefox, one might have the idea to use the Windows Subsystem for Linux as a secure browsing environment to guard Windows against the diverse dangers of the web. But as mentioned above, all local drives are mounted by default in the system and every Linux process can, by default, read from and write to that drives. To change that, the Windows Subsystem for Linux introduces the configuration file
/etc/wsl.conf. The content of this file is formatted according to any Windows ini file: a text file with section names in square brackets, followed by key-value-pairs. This is an example configuration file with, at the time of the writing of this post, all possible keys set to their default value:
The most radical way to secure the environment would be to set the key
false in section
automount. No drives are mounted any more and no malware can change data outside of the virtual file system. But that also means that you cannot access any data on your windows drives to, for example, upload files.
To allow at least read access to the drives, you can set the
options key in section
automount to the value
Another attack vector from inside the WSL would be to start a windows program to change data, as any windows process can access the Windows drives and also runs with the access rights of the user starting the WSL command shell. To change this, just set the key
false in section
interop. This way, no Windows program can be started from a Linux process.
So a minimal example of the
/etc/wsl.conf file to prohibit malware access to any Windows drive would be
In most cases, though, people installing the Windows Subsystem for Linux may want to use the advantages of using Linux tools also with their Windows files.
If you want to know more about the possibilities of configuring the file
/etc/wsl.conf you can read all about that in Automatically Configuring WSL.
Installing a graphical editor
As a software developer, I first need an editor to create and edit the source code. So let’s try to install the more and more popular Visual Studio Code.
At this point, we have a problem. Visual Studio Code is based on Electron, an open-source framework allowing for the platform-independent development of desktop GUI applications. Unfortunately, Electron does not run in a graphical environment without graphics acceleration. This is not a problem inherent to WSL, but to every remote graphics terminal, especially XRDP. To make it run, one can patch the library file
/usr/lib/x86_64-linux-gnu/libxcb.so.1, but that may break other applications relying on that library. The best solution seems to be to create a local patched copy of the library and use it just for VS Code:
To finally start Visual Studio Code, we can now use the following command line, setting the dynamic loader path so Visual Studio Code uses the modified library:
And again, if all is set up correctly and the X Server is running, the Visual Studio Code window opens on the Windows desktop.
Do you prefer Atom? No problem:
Since Atom is also based on Electron, we just use the same local patched library version to run the application without graphics acceleration. If you didn’t install Visual Studio Code before, you first have to create the patched local library as described above.
The installation of Sublime Text is just as easy:
And if you are still not convinced that the Windows Subsystem for Linux might be a viable alternative for developing Linux software you can just install Eclipse:
Installing a graphical file manager
To round it up, I tried to install some graphical file manager. GTK based graphical applications normally need the
dbus-x11 package, so it’s best to install that first:
GNOME/GTK based file manager like Nautilus and Gnome Commander seem to mostly work. As there is no real desktop installation, Nautilus complains about the trash not being existent and just plain stops when clicking on the Desktop icon, unless a folder named “Desktop” is present in the home directory. Gnome Commander only complains about missing icons. Nemo, a Nautilus fork for the Cinnamon desktop environment, seems to work, but strangely brings its own desktop window.
With KDE based file manager your mileage may vary: Dolphin installs and runs in principle, but generates a lot of warnings in the terminal and the visual representation is broken. Konqueror installs and, despite some warning messages in the terminal, seems to run without problems. The graphically simple file manager Krusader installs and seems to work.
Where to go from here
There is already a lot of documentation about the Windows Subsystem for Linux available on the web. Below I have collected some links containing a lot of advanced information which go well beyond the scope of this post. And of course, it will be very interesting which developments in interoperability we will see in the future: a Windows Subsystem for Mac OS, maybe?