There's more to WSL than Ubuntu

Microsoft's Windows Subsystem for Linux is a useful tool. How can you get more out of it?

The top TechRepublic downloads of 2018

One of the more interesting aspects of recent Windows 10 builds is support for the Windows Subsystem for Linux (WSL). Designed to make Windows more attractive to developers, WSL lets you run a full Linux install on Windows, translating Linux system calls to Windows calls and allowing you to run Linux without needing a Linux kernel.

Setting up WSL is easy enough; all you need to do is enable feature support for WSL and download a distribution from the Windows Store. Most users will gravitate to Ubuntu, as it's the most popular distro currently available and was the version Microsoft initially shipped with the first WSL implementations. However, the choice in the Windows Store is bigger and more interesting than Ubuntu. Alongside it you'll find two releases of SuSE Enterprise Server (12 and 15), Debian, and Kali Linux.


As well as Ubuntu, you'll find SuSE, Debian and Kali Linux in the Windows Store.

Image: Microsoft

Choosing a distro

By integrating WSL with the updated Windows command-line environment, it's possible to integrate it directly with any application that offers a terminal. You can write code in Visual Studio Code, save it directly to a Linux filesystem, and test it from the built-in terminal, all without leaving your PC. And when it's time to deploy to a build system, you don't need to worry about line-ending formats or having to test code on separate systems. Support for SSH also ensures that you've got secure remote access to any Linux servers, in your data center or in the cloud.

If you're using WSL to develop and test server applications, then you'll probably want to install SuSE Enterprise Server. It's a popular Linux server, and can be configured to handle most server tasks. With WSL now supported on Windows Server, you can use it to build test environments for cloud applications before deploying them on Azure or another public cloud. SuSE bundles a one-year developer subscription, which gives you more support resources than its standard community-based support forums.

SEE: Windows 10 power tips: Secret shortcuts to your favorite settings (Tech Pro Research)

One of the more interesting options is Kali Linux. Intended for use by security professionals, it's a version of Debian that comes bundled with a wide selection of security tools -- with a focus on penetration testing. It's certainly not for everyone as it bundles several hundred different tools for exploring and cracking network security. Red and blue teams will find it useful, as it contains the tools most attackers are likely to use.

Running Kali from Windows systems can help identify issues with your network and servers, helping reduce overall risk. However, we'd recommend you don't install it on business PCs without permission from IT departments, as running it can trigger alerts from existing security systems.

Adding new distros to the Store

Microsoft's policies around certifying Linux distributions for WSL are reasonably flexible; the only real requirement is that any distribution submitted to the Windows store needs to come from an official source. That makes sense, testing any random submission completely would be uneconomical. Instead, by tying a WSL installation to a trusted source Microsoft is adopting the same trust model as any direct Linux user.

That does initially limit the choice you have to those distributions that have chosen to repackage their root file systems for the Windows Store. While many major distributions are there, others -- like RedHat's Fedora or the server-focused Centos -- haven't arrived yet, and nor have any container-focused small distributions.

Rolling your own

However it's not the problem it might seem, as one of the more interesting aspects of WSL is that you're not limited to the distributions in the Windows store. If there's a specific one you need for a specific task, then you can make it yourself and sideload it into Windows 10.

Building your own WSL distribution isn't simple. You will need to start by building a launcher app, based on the open-source sample from Microsoft's WSL GitHub repository. The launcher is a relatively simple tool that exposes specific WSL functionality to both users and to the distro you're using. Once you've written your own version, and given it an appropriate name, you'll be able to use to launch a WSL shell prompt in a user directory, install the distribution you're using, and run command lines in a working directory (a useful developer tool that lets you mix WSL Linux commands in Windows scripts).

To install a Linux distribution you'll need to include a tar file of a root file system, either making your own from a running Linux system or downloading one from an archive. You'll find copies of most common distributions relatively easily, including the one major distribution missing from Microsoft's curated selection in the Windows Store, Fedora. There's also an option of making an image from a container's root file system.

LxRunOffline: a WSL shortcut

There are alternatives to building a WSL distribution from scratch, with third-party tools that can go straight from a Linux archive to a running installation. Most are command-line tools, so are intended for a developer or system administrator audience. One of the more interesting options, LxRunOffline, can be found on GitHub or via the Chocolatey application distribution service. Once you've installed and registered it on a Windows system, it can take a downloaded Linux image and, with a single command line, install it on your Windows machine.

Using this tool I was able to get a Fedora installation up and running in less than 15 minutes. This is not a way of distributing non-standard Linux distributions to end users, but it's a useful tool for developers who want to test specific Linux functions on their Windows machines. One important note: LxRunOffline will only create a root user, so you'll need to create your own users as necessary. There's also no start menu entry, although it does create a desktop shortcut to a command line that you can add to your Start manually.

SEE: 20 pro tips to make Windows 10 work the way you want (TechRepublic download)

Running Linux tools directly on Windows makes building for platforms like Microsoft's own Azure Sphere easier. Unix dev tools, test environments and all the various components of a modern development environment can all live side by side with Windows' own productivity tooling. It's an effective combination, and one that had until recently made Apple's Macintosh a popular developer platform.

WSL has gone a long way to changing that perception, with devices like the Surface Pro and Surface Book now common sights at developer events, where once there were ranks of glowing Apple logos. Now that there's a growing number of Linux distributions in the Windows Store, and tools that let you roll your own WSL installations, Windows looks likely to regain its place as the developer tool of choice.

Also see