The introduction of the Windows Subsystem for Linux (WSL) has been a game-changer for developers who use both Windows and Linux. With WSL, users can run a Linux distribution natively within Windows, eliminating the need to dual boot or use virtual machines. This seamless integration provides the best of both operating systems on one machine.
In this guide, we will explain how to install and set up WSL and the newer WSL 2 on Windows 10 and Windows 11. WSL 2 offers significant improvements in filesystem performance and full system call compatibility for increased Linux compatibility.
What is Windows Subsystem for Linux (wsl/wsl 2)?
The Windows Subsystem for Linux (WSL) allows you to natively run Linux on Windows. This lightweight compatibility layer integrates Linux tools into the Windows environment without virtual machines or dual boot. WSL provides a streamlined experience to leverage Linux command line utilities within Windows.
What is the Use of Windows Subsystem for Linux?
With WSL, developers can develop applications for both Windows and Linux operating systems. With this technology, Linux-based applications can be developed and tested natively on Windows without the need for a separate Linux machine. This allows you to work on cross-platform projects with a seamless workflow.
As a result of WSL, Linux developers no longer have to switch between operating systems when developing on Windows. Now you can develop, build, and run Linux apps with integrated tools within the familiar Windows environment. WSL offers a simplified solution for Linux-based tooling on Windows, regardless of whether you are an experienced developer or just getting started with Linux.
How to Install Windows Subsystem for Linux (WSL/WSL2) on Windows 10 or Windows 11
Make sure that your Windows 10 or Windows 11 is running the newest version of 20H2 or higher to install wsl or to install wsl 2 and active internet connection before you begin the installation. Now follow these steps to install WSL or upgrade to WSL 2 on your Windows 10 or Windows 11 machine:
- Enable WSL Feature:
- Open the Start menu and search for “Turn Windows features on or off.”
- Scroll down and enable both “Virtual Machine Platform” and “Windows Subsystem for Linux.”
- Next, restart your system.
- Open PowerShell as an administrator (right-click and select “Run as administrator”).
- Run the command:
wsl –install
- This command automatically installs all the required components automatically.
- Next, Restart your system.
- Run the command:
‘Alternatively, if you don’t want to run the code, you can download your favorite Linux Distribution from the Windows Store. Search for a Linux distribution in the Microsoft Store (e.g., Ubuntu, Debian, Fedora) and install it and open it. That’s it.’
- Now open the Start Menu and look for Ubuntu.
- Open it and set a username and password. Now you are good to go.
If you install WSL on your Windows 11 or Windows 10 system or, if you already have WSL installed on your system you can update it with a few simple steps.
- To install or Update wsl to wsl2 on your Windows 10 or Windows 11 system:
- Open PowerShell as an administrator (right-click and select “Run as administrator”).
- Run the following command to update WSL to WSL 2 :
wsl –update
- Now Run the following command to set WSL 2 default:
wsl --set-default-version 2
Question and Answer
Q1: Which is better, WSL or VirtualBox?
It depends on your use case. WSL provides better integration between Windows and Linux, making it ideal for development. VirtualBox offers a more isolated environment but may have a bit more overhead.
Q2: Is WSL better than dual boot?
WSL is often preferred over dual booting as it allows you to switch between Windows and Linux quickly without restarting your computer. Dual booting requires rebooting the system to switch between the two.
Q3: Does WSL take a lot of RAM?
WSL generally consumes less memory compared to a full virtual machine setup. The memory usage largely depends on the applications you run within the Linux environment.
Q4: Is WSL a full Linux installation?
WSL provides a complete Linux environment, but it’s not an entirely independent installation. It shares the Windows kernel while offering Linux user space utilities and tools.