Skip to content

Windows Subsystem For Linux (WSL)

Published On:
Sep 11, 2022
Last Updated:
Sep 11, 2022

Command-Line

You can jump into the WSL by typing wsl inside a Windows terminal:

Terminal window
wsl

It will jump into the WSL and set the current working directory to the same directory as in Windows, e.g. if you were in C:\Users\username\ in Windows, when you type wsl it will land you at /mnt/c/Users/username/.

VS Code has an extension for WSL. It allows you write/run code inside WSL whilst editing in VS Code running in Windows (i.e. the same way VS Code supports remote development).

From inside WSL, if you type the command code ., it will open at VS Code in Windows and setup a remote development session into WSL at the current working directory.

wsl --shutdown

Must be run from terminal with Administrator privileges:

wsl --upgrade

You can set the default distribution with:

wsl --set-default <distro-name>

The default distribution is the one which will load if you just type wsl at the command-line in Windows.

Upgrading From WSL 1 To WSL 2

If you first enabled/installed WSL a long time ago, you might be running WSL 1. WSL 2 is a big upgrade over WSL 1 — WSL 1 used a “wrapper” to convert Linux system calls into Windows calls, whilst WSL 2 features a full Linux virtual machine (similar to VirtualBox).

Passing Through USB Devices

WSL 1 and 2 do not natively support USB pass-through like VirtualBox does. However, there is a popular 3rd party tool called usbipd-win which can do the job. There was a update to WSL 2 to allow usbipd-win to work without too much hassle.

Windows software for sharing locally connected USB devices to other machines, including Hyper-V guests and WSL 2. — usbipd-win.