About Collections Archives

Debian on Windows via WSL

3 min read

Debian is well known for its legendary stability. These days, with the help of Windows Subsytem for Linux (WSL), Debian’s rich sets of tools and utilities are also available to millions of Windows users.

When you activate Windows 10 feature called Windows Subsystem for Linux (WSL), it will download and install Ubuntu Linux (as of now, version 12.0414.04). It will be made available as “Bash on Ubuntu on Windows”. But instead of Ubuntu, is it possible to use Debian? Fortunately, there is this WSL Distribution Switcher project that allows switching the baseline Linux OS for WSL.

To switch to Debian, first we need to clone the repository (assuming Git is installed and available from PowerShell):

> git clone
> cd WSL-Distribution-Switcher

Next step is to grab Debian itself, for instance its latest stable version, Jessie (this requires Python):

> python debian:jessie
> python debian:jessie

The script grabs the root file system (from Docker image downloaded from Docker Hub) and unpacks it in the local AppData directory (e.g. C:\Users\ariya\AppData\Local\lxss in my system).

Before we launch Debian, we need to fix the situation with sudo. This is done by switching the default user for WSL to root and launch bash:

> lxrun /setdefaultuser root
> bash

At this stage, we are already inside Debian. Now it is time to install sudo (as Docker image’s rootfs often does not have it) and to ensure that your user account is in the sudo group:

$ apt-get update
$ apt-get install sudo
$ adduser ariya sudo
$ exit

Back to PowerShell, restore the default user for WSL and launch bash for real:

> lxrun /setdefaultuser ariya
> bash

To prove that is really Debian:

$ cat /etc/debian_version

Or in a more detailed fashion:

$ sudo apt-get install -y lsb-release
$ lsb_release -da
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 8.7 (jessie)
Release:        8.7
Codename:       jessie

Since this is just a regular Debian system, we can do many things. For instance, we shall be able to run Lua:

$ sudo apt-get install -y lua5.2
$ cat << EOF > hola.lua
> print("Hello from Lua on Debian via Windows")
$ lua hola.lua
Hello from Lua on Debian via Windows

But hey, it’s so much fun to use LuaJIT. And perhaps we shall not install the prebuilt package but rather compile it from its source code. After grabbing the source tarball, e.g LuaJIT-2.0.4.tar.gz, what we need to do:

$ sudo apt-get install -y build-essential
$ tar zxf LuaJIT-2.0.4.tar.gz
$ cd LuaJIT-2.0.4
$ make
$ src/luajit hola.lua
Hello from Lua on Debian via Windows

The above steps demonstrate that WSL running Debian can be a perfectly working environment for application development.

Now, what do you plan to do with this new superpower?

Related posts:

♡ this article? Explore more, check the archives, or follow me Twitter.

Share this on Twitter Facebook Google+

comments powered by Disqus