The Windows Subsystem for Linux (WSL) lets developers run a GNU/Linux environment — including most command-line tools, utilities, and applications — directly on Windows, unmodified, without the overhead of a traditional virtual machine or dual-boot setup.
WSL1 VS WSL2
The primary reasons to update from WSL 1 to WSL 2 are to:
- increase file system performance
File intensive operations like git clone, npm install, apt update, apt upgrade, and more are all noticeably faster with WSL 2.
The actual speed increase will depend on which app you’re running and how it is interacting with the file system. Initial versions of WSL 2 run up to 20x faster compared to WSL 1 when unpacking a zipped tarball, and around 2-5x faster when using git clone, npm install and cmake on various projects.
- support full system call compatibility
Linux binaries use system calls to perform functions such as accessing files, requesting memory, creating processes, and more. Whereas WSL 1 used a translation layer that was built by the WSL team, WSL 2 includes its own Linux kernel with full system call compatibility. Benefits include:
- A whole new set of apps that you can run inside of WSL, such as Docker and more.
- Any updates to the Linux kernel are immediately ready for use. (You don’t have to wait for the WSL team to implement updates and add the changes).
WSL 2 uses the latest and greatest in virtualization technology to run a Linux kernel inside of a lightweight utility virtual machine (VM). However, WSL 2 is not a traditional VM experience.
Install a specific Linux distribution:
wsl –install –distribution <Distribution Name>
List available Linux distributions:
wsl –list –online
Set WSL version to 1 or 2:
wsl –set-version <distribution name> <versionNumber>
Set default Linux distribution:
wsl –set-default <Distribution Name>