What is WSL?
WSL is the Windows Subsystem for Linux. If you’re familiar with Linux, this is a feature which lets you run Linux inside Windows. I know what you’re thinking, why would I want to do this? There are many reasons but the most common one is software development. Also, if you’re more familiar with Linux tools, you can use them to interact with the Windows system rather than relying on the Windows tools.
WSL allows you to install and run Linux programs and tools on pretty much any Linux distribution. From Ubuntu to Debian. Check the Microsoft Store for your favorite Linux distribution to see if there’s a version which supports WSL. Setup is quite simply. The process invloves installing your favorite distribution from the Microsoft Store, launching it Once WSL is setup, it behaves like any normal Linux install. To access a mounted drive on Windows, you must look in the /mnt folder.
For example to change to the C:\ drive run:
This allows you to easily interact with the files stored on your local machine while using Linux utilities. If you wanted to update WSL, all you’d need to do is run the distributions package manager. For example in Debian based distributions use apt:
sudo apt update && sudo apt upgrade
This will check for updates and then install all available updates.
WSL 1 vs WSL 2
WSL 1 is the first iteration. It does not run in Hyper-V and as a result, is not as easily managed. WSL 2 runs a full Linux Kernel in Hyper-V. This enables better compatibility with Linux programs and tools. If you are unable to make up your mind, fear not, for you can change between versions very easily.
To see which version each distribution is running, use:
wsl --list --verbose
To change between versions use:
wsl --set-version Ubuntu 1
Where Ubuntu is the name of the distribution you want to change and 1 is the version you want to change to.
Should I Use Version 1 or 2?
While WSL 2 is better in most ways, there are specific use cases where WSL 1 would better suit your needs. If you are preforming lots of file operations on hard drives that are formatted in NTFS, WSL 1 is the way to go.
One issue with WSL 2 is that it uses Hyper-V to run the Linux kernel. This adds some overhead but the biggest problem is this can prevent you from using other hypervisors. If you already have a virtual machine setup with VirtualBox or VMware Workstation, using WSL 2 can prevent those machines from working. This is a known problem and Virtualbox and VMware are working on a solution.
Use Case Examples
Lots of games let you host and manage your own server instance. This puts you in control of your game experience while allowing your friends to take part with you. Lots of servers run Linux and as a result of this, most server software is designed to run on Linux. Running on Linux allows for easier management as you can utilize Linux’s command line tools. You could run a Minecraft server, for instance, in WSL. Using a bash script it could automatically reboot the server if it crashes. If we wanted to do something more advanced, the script could backup the server folder and then run the server once the backup has been completed. The ability to access the Windows file system with Linux commands is quite a powerful tool.
Perhaps the best use case is for developers. Lots of software development tools run on Linux and the workflow is often superior to Windows. If you write web applications using Node, you’ll understand this well. The Linux command line is simply better than PowerShell and especially Command Prompt.
If you like using Linux tools but need to run Windows, for whatever reason, this is a fantastic solution. This eliminates the need to dual boot Windows and Linux. You also don’t need to mess with a virtual machine. WSL takes care of everything. I highly recommend WSL if you are familiar with the Linux utilities. You may find a niche use case to integrate the utilities in your Windows workflow.