Windows Subsystem for Linux (WSL) is a Windows-based subsystem that enables Linux to run as a separate process on a computer. This allows for more efficient use of resources, as well as easier access to features and applications that are not available through the normal Windows operating system. To use WSL, you must first install the Windows Subsystem for Linux driver. This driver is required in order to allow WSL to communicate with the Linux kernel. You can also find the driver online or in a Microsoft Update package. Once you have installed the driver, you can start installation of WSL by running the following command: c:\windows\system32\drivers\wsl.sys Once installation has completed, you can start using WSL by running the following command: wsl start
Windows Subsystem For Linux (WSL) is a tool provided by Microsoft to run Linux natively on Windows. It’s designed to be a seamless experience, essentially providing a full Linux shell that can interact with your Windows filesystem.
Not Just a Virtual Machine
Lets start with what WSL isn’t—it’s not a full Linux desktop experience that you might get by running Ubuntu in VirtualBox, for example. It does technically use virtualization for performance reasons, but it’s very different from running a full VM. It’s all managed for you, and just provides a simple shell and environment for you to do your work and use familiar bash commands like git, ssh, and all the other tools that come with the chosen distribution.
Basically, WSL allows you to install a full Linux distribution as an app from the app store. You can simply download Ubuntu (or the distro of your choice), install it, and have it available as a app you can launch, or a profile in your terminal to run alongside CMD or Powershell.
While the simplest explanation is that it “lets you run bash on Windows,” it’s more than just a shell; you can install programs using apt and customize it like a regular Linux instance.
WSL is intended to give developers and bash veterans the Linux shell experience despite having to use Windows as the primary OS. It offers the best of both worlds by allowing you to run Windows apps, like Visual Studio, alongside a Linux shell for easier command line access.
Microsoft offers two version of WSL: version 1, and version 2. WSL 2 uses a virtual machine, and uses a full Linux kernel built and shipped with Windows. WSL 1 is older, and generally a lot slower, but does have better performance when working across filesystems, e.g. accessing Windows files from Linux, and vice versa. We recommend WSL 2 for most operations, as it’s faster and works much better with tools like Docker.
Setting Up WSL
WSL is an optional Windows feature, so you’ll need to turn it on. Open up Powershell as Administrator via the start menu:
Then, turn it on:
You will need to restart your machine to apply the changes. After that, you can open up the Windows Store and search for “WSL,” which will display the available distros:
The first time you run it, you’ll be prompted to set up your username and password for the instance. These are just for Linux, and don’t need to match your windows password at all.
The first one you install should be set as your default, but if you install multiple, you will need to set the default manually. You can manage WSL via the wsl command in Powershell. For example, listing all currently installed versions:
Then, you can set your default WSL distro with the following command, which can also be used to swap between WSL 1 and 2″
You can also set a preferred WSL version (1 vs. 2) for all future installs:
Using WSL
You can open WSL in a few different ways. The easiest is to just press Windows and type “wsl,” which will automatically run wsl.exe and open your default distro.
This is just a basic terminal window though; if you’re using Microsoft’s new Terminal App, which we highly recommend, your WSL versions can be accessible via a dropdown menu (alongside any SSH profiles you may have set up):
In case you want to set up a new profile, the config for this is the following:
A Note On Filesystems
Your Linux filesystem is mounted at /, as per usual. Windows is located at /mnt/c/, or whichever drive letter is your default (additional drives are mounted as well).
Since this is all virtual, your Linux files are of course stored on the drive itself. For WSL 1, these are stored with a simple folder. WSL 2 changes things though, and stores files as a virtual hard disk image, or VHDX.
You can find these images at the following path, and while they can be mounted while the distro is unregistered, we don’t recommend messing with them from the Windows side.