Windows Subsystem for Linux 2.0 Guide

Windows Icon The Windows Subsystem for Linux (WSL and WSL 2) is a project to provide a Linux shell in Windows 10. With version 2, WSL provides a full blown Linux Virtual Machine with a Linux kernel. Therefore, after installation, you have a full Linux installation BUILT-IN to Windows 10. This makes your Windows PC or laptop on par with a Mac for running Linux. In fact it might be better.

WSL 2 Installation and Docker

To install WSL 2 you need to follow these steps.

Requirements

Manual Install Method

Upgrading from WSL 1 to WSL 2

Believe it or not, if you had WSL 1 installed, the system will not switch you to version 2 automatically! Use the following commands to check and set.

Configure Docker Desktop (Optional: Requires Docker Install)

Note: If you don't know what Docker is, skip this section.

Once you have WSL 2 installed, Docker will detect WSL and then ask you if you would like to switch to WSL as your default VM. Choose Yes to switch.

After you select the switch, make the following changes to Docker.

Once you have done that, you can run Docker commands from Windows or from a Linux terminal. Very slick.

Removing an old version of WSL

If you played around with the early beta versions of WSL, you may need to uninstall it. To do that run:

lxrun /uninstall /full

That should get rid of the old version. If that doesn't work, try:

WSL Tips

Access the Windows 10 Filesystem from Linux

Access Linux Filesystem from Windows

Windows 10 WSL Mount External Drive

After you do that, D: should automount every time after that.

Terminate your WSL 2 Instance

You can terminate your WSL 2 instance from the Windows command line.

Reference: https://winaero.com/terminate-running-wsl-linux-distro-windows-10/

Useful WSL Commands

Run Windows Apps

Details can be found on SuperUser

The newest versions allow you to just execute what's in the path:

$ export PATH=$PATH:/mnt/c/Windows/System32
$ notepad.exe
$ ipconfig.exe | grep IPv4 | cut -d: -f2
$ ls -la | findstr.exe foo.txt
$ cmd.exe /c dir

WSL 2 Resources