The Windows subsystem for Linux

If you have a Windows 10 system and are interested in studying computer science, you will want to install the Linux subsystem (the official Microsoft name is "Windows Subsystem for Linux", or WSL).

The Linux subsystem is a full-fledged Linux that runs as an application inside Windows 10. This means you can enjoy all that Linux goodness without any of the hassles of making your machine dual-boot or installing a virtual machine!

Why install the Linux subsystem?

The two main software ecosystems in the laptop/desktop world are Linux (and its progenitor Unix) vs. Windows.

Because its is free and open source, Linux is the more common alternative to Windows. If you have a Mac, you are running Unix.

Windows is an excellent platform for tasks such as creating spreadsheets and writing Christmas letters. It is not, however, a useful software development environment without extensive, frustrating, and sometimes costly customization that requires numerous third-party tools that often do not work together.

On the other hand, Linux and Unix have seamless software environments that make them perfect for programming and experimentation. For instance, in a current Linux distribution, if you want to write code in the C programming language all you need to do to install the necessary software is to type something like

sudo apt-get install gcc

at the command line and hit RETURN.

How do I install the Linux subsystem?

The offical installation instructions are here. In particular, be sure to enable the "Windows Subsystem for Linux" option as described at the start of the page.

Select the Ubuntu 18.04 LTS distribution (this will keep our Linux subsystems consistent across CS). You can find it in the Microsoft App store.

Very important!

  1. The first time you launch the Linux subsystem you will be prompted to create a user account. Make sure you do so, and you remember the Unix userid and password you set. The account you set up here will make you a superuser, meaning you can easily install software in the Linux subsystem. If you miss this step, the simplest thing to do is uninstall and reinstall the Linux subsystem.
  2. Before you install any software using apt-get, first run
    sudo apt-get update
    to update the package lists.

Linux is Linux and Winders is Winders, and never the twain shall meet!

The Microsoft Windows 10 Linux subsystem blog warns:

DO NOT, under ANY circumstances, access, create, and/or modify files in your distro's filesystem using Windows apps, tools, scripts, consoles, etc.

😱 If you do, Very Bad Things may happen to the Linux subsystem. 😱

More information can on this topic can be found here.

Windowing applications inside WSL

In order to run windowing applications (e.g., Emacs, the Greatest Editor Ever!) inside WSL and have them appear on your Windows screen, you will need to install an X server on the Windows side.

In addition, you will need to set the DISPLAY bash variable:

DISPLAY=:0.0 # No spaces around the equal sign!!
export DISPLAY

I suggest you include these two lines in ~/.bashrc.