Running Ubuntu on Windows 10 with WSL2 (Windows 11 update)

Mauro Giusti
7 min readApr 19, 2020

Linux or Windows?

Note: This is the first of a series of articles about running Ubuntu on Windows 10, check out the follow up: Part 2: Windows Terminal and Part 3: Visual Studio Code and go

December 2021 update with Windows 11:

With newer versions of Windows (including Windows 11), you can set up WSL 2 simply by running wsl --install . This will update the appropriate settings to enable WSL and update the Linux Kernel to the latest version.

Open PowerShell as Administrator, then list the available distros for WSL with:

PS C:\Users\maurgi> wsl --list --online
The following is a list of valid distributions that can be installed.
Install using 'wsl --install -d <Distro>'.
NAME FRIENDLY NAME
Ubuntu Ubuntu
Debian Debian GNU/Linux
kali-linux Kali Linux Rolling
openSUSE-42 openSUSE Leap 42
SLES-12 SUSE Linux Enterprise Server v12
Ubuntu-16.04 Ubuntu 16.04 LTS
Ubuntu-18.04 Ubuntu 18.04 LTS
Ubuntu-20.04 Ubuntu 20.04 LTS

To install WSL2 with the Ubuntu default, simply run:

PS C:\Users\maurgi> wsl --install Ubuntu

This will do all the magic for you.

For more details, look at the Microsoft web site: Install WSL.

For older versions of Windows, you can still follow my step by step guide here:

With the release of Windows 10 May 2020 Update (version 2004), it is about time to share how I have been running a full Linux workload on my Windows 10 machine with WSL2 for more than a year.

I have been part of the Azure Kbernetes Services (aks) team at Microsoft, working on Service Reliability (SRE) and focusing on monitoring, ci/cd automation and toil reduction for about a year and a half now. I do anything I need there using WSL2 (the Windows Subsystem for Linux version 2), Visual Studio Code and Docker Desktop on Windows 10, where I feel more at home (and I can game too).

I was relatively new to Linux workloads when I joined this team, before settling on WSL 2, I tried WSL, a Linux VM and a Mac, but they all had some downsides compared to my current configuration, so let me share with you how I got there.

My first attempt was to create a Linux VM and run it on Azure. The result was dece, I was able to ssh in with Moba XTerm or conEmu, run Docker and build my go code no problem, but editing was a pain. You don’t want to write code on a VNC or RDP connection, as there is lag involved with your keystrokes and over time it becomes frustrating. This was before VS Code had good Remote Development support, Code Server remoting via ssh was in beta at the time, and I had to set it up myself on the VM, but sometimes it would go down. The dealbreaker for me was the lack of productivity tools on Ubuntu Desktop, missing the Office suite meant I had to run everything on the browser or switch between machines all the time and this felt sluggish, while I wanted to go fast!

Next step, I got myself a MacBook Pro and configured it all up. This was definitely a step up, everything was native with the Mac: Docker, ssh, bash, go are at home there, and Visual Studio Code did a magnificent job of not making me feel too stranger to the Mac platform, behaving exactly the way I remembered it on the PC.

With the use of Karabiner I was able to remap ctrl+c / ctrl+v and Home/End to my likings but this was this setting was not respected by all apps, for example on Chrome, editing our Wiki was hard as Home and End were going to top and end of the page and my brain kept pressing them whenever I wanted to go to the beginning/end of the line, again speedbumps slowing me down.

Also, some of the security configuration in my company prefers the Windows integration, so it was a bit of a pain with the Mac (no smartcards support!) as I had to switch to my PC to run some tasks.

I had tried WSL before, but, besides the slow file system speed, the mayor dealbreaker was the inability to use Docker without exposing the daemon outside of TLS. Nik Janetakis’ article explained this very well but I did not feel secure enough to run my service with this configuration. I also had issues with Minikube, and Docker for Windows was not an alternative yet, so I passed.

When WSL2 finally got in beta during the summer, and Docker for Windows announced the support for WSL2, I decided to give it a try. I have been running that configuration for more than 6 months now, with nothing but good times.

The right version of Windows 10

To install WSL2 you will need at least Windows 10 May 2020 Update. At the time of this update (August 2020), most people should have received the update and running the correct version.

To check, press the Windows+R keys and run winver.exe , you should see your version of Windows 10:

If you have an older version, check Microsoft article on how to Get the Windows 10 May 2020 Update or check out my older article on how to Install Windows 10 May 2020 Update via Winodws Insider Program.

Installing WSL2

Now that you have the right version of Windows, you can install WSL2. Following the instructions here, the first thing is to enable both the Windows Subsystem for Linux and the Virtual Machine Platform optional components.

Open PowerShell as an admin and run the following script:

After the script is complete, you need to reboot your machine, since this enables new Windows features.

Once your PC has rebooted, we need to update the WSL 2 Linux kernel. Go to https://aka.ms/wsl2kernel and follow the download link, an msi installation will complete the update:

OK, now it is time to set WSL2 to be the default for all WSL installations. Trust me, you don’t need to use WSL version 1 ever again. Open PowerShell and run:

The result is not very exciting, but it will come handy soon.

Installing Ubuntu on WSL2

Now it is time to install your favorite Linux distro. As per the instructions here, open the Microsoft Store app and type Linux in the search box, all the available distros show up:

I run Ubuntu 18.04 TLS, but you can select the one you prefer and click Install:

Once it is installed, press Launch:

If you get lost, you can always type Ubuntu from the Start menu and run it from there:

The first launch will do the actual installation and will take a few seconds. The setup will also ask you for a username and a password for your distro configuration:

Now open PowerShell and ensure that WSL is correctly using version 2 for your distro:

wsl --list -v

If this is still showing version 1, you can run the upgrade command:

wsl --set-version Ubuntu-18.04 2

There, you have a shiny full Ubuntu distro on your PC, you can open your Ubuntu shell and (proudly) check the version:

Until next time

That is it for now, if you want to know more about installing and configuring the new Windows Terminal to make it look just like iTerm2 on my Mac, check out my follow up post: Part 2: Windows Terminal.

Check out Part 3: Visual Studio Code and go, for configuring VS Code and golang on Ubuntu in Windows 10 with WSL2.

Ciao.

--

--