Running Linux on Windows 10

INTRODUCTION

Often developers and related OPs need to test stuff on Linux (web, cli, .NET Core etc.). The typical approach was to spin up a Virtual machine (VM), install and configure a Linux distro and play with it.

Main Cons include: you need a hyper-visor software, enough RAM, fast hard drive, to fight with basic operations like cope-paste text and files between machines etc.

Well, good news! As of the Anniversary Update Windows 10 supports the so called “Windows Subsystem for Linux” (WSL). It allows you to run natively* most of the non GUI Linux stuff**on Windows without the overhead of a virtual machine.

When you start Bash it will appear within standard Windows console window (since it is hosted by ConHost.exe). Therefore you can benefit from both Bash’s colors and beauty and Windows’ console window transparency, fonts and settings:

* WSL is a result of many years of work and combines different projects (like Drawbridge) together with some User/Kernel support.

In fact Linux apps run in a sandbox and all api/system calls are translated in a way that Windows will understand. This is kind of application virtualization.

** There is a way to start a Linux GUI app under Windows usingXming X Server for Windows. Here is a little how-to article.

Of course it comes with some limitations since no real Linux Kernel is running on the Windows box. But it’s fairly enough for day-to-day dev & test tasks.

It’s worth to say that running Linux on Windows i primarily intended for dev & test and not for running heavy websites & databases in production since Shell’s virtualization comes with performance costs.

I’d also recommend you to watch Scott Hanselman’s intro to Bash on Ubuntu on Windows. He is explaining a lot!

HIGH LEVEL STEPS

  1. Enable WSL support
  2. Choose and install a Linux distro from Windows Store
  3. Configure your Linux distro

DETAILED STEPS

WSL evolved through the last few Windows 10 updates and betas as well as the installation/configuration steps. This guide applies to Windows 10 1709. Also we will install Ubuntu.

  1. Install WSL
    1. Via PowerShell:
    2. Via Control Panel:
      1. Open “Windows Features”: Control Panel > Programs > Turn Windows features on or off
      2. At the bottom of the list select “Windows Subsystem for Linux” and click Ok:
  2. When prompted restart your computer
  3. Install Linux distribution (two ways to do it):
    1. In the Start menu search for Bash and start it. You will be provided a hyperlink. Open it in the Browser. This will start Windows Store from where you can pick a distro. Click and install Ubuntu.
    2. Open Windows Store and search for Ubuntu. Click on the icon and install it.
  4. Wait for the installation to complete
  5. In the Start Menu search for Ubuntu or use the desktop shortcut.
  6. The first time you will be asked for a username and a password

That’s it!

Now let’s have some Linux fun on out Windows box:

1) Force ipv4 to avoid apt-get delays:

2) Update our Linux distro:

3) Install mc (Midnight Commander)

4) Install Apache2

4.1) Modify default ports to avoid collisions with IIS/Skype

4.2) Restart Apache

4.3) Test Apache on your Windows box

BEAUTY!

TIPS

  1. Making Ubuntu on Windows a bit more Authentic
  2. Windows 10’s Bash shell can run graphical Linux applications with this trick

ADDITIONAL RESOURCES

  1. Windows Subsystem for Linux Overview
  2. Frequently Asked Questions about WSL
  3. Windows Subsystem for Linux Documentation
  4. User Accounts and Permissions
  5. WSL on GitHub
  6. Command Line Blog
  7. WSL Blog

Leave a Reply

Your email address will not be published. Required fields are marked *

*