What is WSL2? How to Install and Use Linux on Windows 11
8 min read
Windows 11 is designed to work well with modern development tools, and one of its most useful features for developers, system administrators, students, and Linux enthusiasts is Windows Subsystem for Linux 2, commonly called WSL2. It allows a person to run a real Linux environment directly on Windows without setting up a traditional virtual machine or replacing the operating system. With WSL2, Windows users can open a Linux terminal, install Linux packages, run command-line tools, develop software, and work with files across both operating systems.
TLDR: WSL2 is Microsoft’s modern version of Windows Subsystem for Linux, allowing Linux distributions to run on Windows 11 using a lightweight virtualized Linux kernel. It is useful for development, scripting, server administration, and learning Linux without leaving Windows. Installation is usually as simple as running wsl --install in Windows Terminal. After setup, a user can install Ubuntu or another Linux distribution, run Linux commands, and access files from both Windows and Linux environments.
What Is WSL2?
WSL2 stands for Windows Subsystem for Linux 2. It is a compatibility layer and virtualization-based feature that enables Linux distributions to run inside Windows 11. Unlike the original WSL, which translated Linux system calls into Windows system calls, WSL2 uses a real Linux kernel running inside a lightweight virtual machine. This makes it more compatible, faster for many workloads, and better suited for modern Linux development.
In practical terms, WSL2 lets a Windows 11 user install distributions such as Ubuntu, Debian, Kali Linux, Fedora Remix, or openSUSE. Once installed, the distribution behaves much like a regular Linux environment. The user gets a terminal, a Linux file system, package managers, shell tools, SSH, Git, Python, Node.js, Docker support, and many other utilities.
Why WSL2 Matters
WSL2 is important because many development and server tools are designed first for Linux. Web servers, cloud tools, container workflows, automation scripts, and open-source utilities often work best in a Unix-like environment. Before WSL, Windows users often needed dual-boot setups, full virtual machines, or remote Linux servers to get a similar workflow.
With WSL2, that workflow becomes much simpler. A developer can use Windows applications such as Microsoft Edge, Visual Studio Code, Office, and design tools while also running Linux commands in the same workstation environment. This combination is especially helpful for web development, DevOps, cybersecurity training, data science, and backend programming.
WSL1 vs WSL2
Although both WSL1 and WSL2 allow Linux programs to run on Windows, they work differently. WSL1 uses a translation layer to convert Linux system calls into Windows-compatible instructions. It starts quickly and can be efficient when working heavily with Windows files. However, it is not fully compatible with all Linux software.
WSL2, on the other hand, uses a real Linux kernel. This provides much better compatibility and improved performance for many Linux-native tasks, especially package installation, compiling code, running containers, and working within the Linux file system. For most modern users, WSL2 is the recommended option.
- WSL1: Lightweight translation layer, useful for some file operations across Windows.
- WSL2: Real Linux kernel, stronger compatibility, better for development and containers.
- Recommended choice: WSL2 for most Windows 11 users.
System Requirements for WSL2 on Windows 11
Most Windows 11 computers can run WSL2, but a few requirements should be met. The system needs virtualization support, which is usually available on modern processors from Intel and AMD. Virtualization must also be enabled in the computer’s BIOS or UEFI settings. In most new systems, this feature is already turned on.
WSL2 also requires an updated version of Windows 11. If installation fails, the system may need Windows Update to be run first. Microsoft regularly improves WSL, so keeping Windows current is a good practice.
- Operating system: Windows 11
- Processor: Modern 64-bit CPU with virtualization support
- Virtualization: Enabled in BIOS or UEFI
- Internet connection: Needed to download WSL and Linux distributions
- Microsoft Store access: Helpful for installing or updating distributions
How to Install WSL2 on Windows 11
Installing WSL2 on Windows 11 is straightforward. Microsoft has simplified the process so that most users only need one command. The installation can be done from Windows Terminal, PowerShell, or Command Prompt, preferably opened with administrator privileges.
- Open the Start menu.
- Search for Windows Terminal or PowerShell.
- Right-click it and choose Run as administrator.
- Enter the following command:
wsl --install
This command enables the required Windows features, installs WSL, sets WSL2 as the default version, and usually installs Ubuntu as the default Linux distribution. After the process finishes, Windows may request a restart. Once the computer restarts, the Linux setup continues automatically.
Choosing a Linux Distribution
By default, WSL often installs Ubuntu, which is a popular and beginner-friendly Linux distribution. However, WSL supports multiple distributions. A user can view available distributions by running:
wsl --list --online
To install a specific distribution, the command can include its name. For example:
wsl --install -d Debian
Common WSL distributions include:
- Ubuntu: Popular, beginner-friendly, and widely documented.
- Debian: Stable and lightweight.
- Kali Linux: Often used for cybersecurity learning and testing.
- openSUSE: A strong option for users familiar with SUSE systems.
- Fedora Remix: Useful for users who prefer Fedora-based workflows.
Setting Up Linux After Installation
When the Linux distribution starts for the first time, it asks the user to create a Linux username and password. This account is separate from the Windows account. The password is used when running administrative Linux commands with sudo.
After the account is created, it is a good idea to update the Linux packages. For Ubuntu or Debian, the following commands are commonly used:
sudo apt update
sudo apt upgrade
The first command refreshes package lists, while the second installs available updates. This helps ensure that the Linux environment is secure and ready for use.
Basic WSL2 Commands
WSL2 can be managed from Windows Terminal using simple commands. These commands help users launch Linux, list installed distributions, shut down WSL, or change versions.
wsl— Starts the default Linux distribution.wsl --list --verbose— Shows installed distributions and whether they use WSL1 or WSL2.wsl --shutdown— Stops all running WSL instances.wsl --set-default-version 2— Sets WSL2 as the default for future installations.wsl --set-default Ubuntu— Sets Ubuntu as the default distribution.
Using Linux Files and Windows Files
One of the most convenient parts of WSL2 is file sharing between Windows and Linux. From inside Linux, Windows drives are mounted under /mnt. For example, the Windows C drive is available at:
/mnt/c
A user can move into the Windows desktop folder with a command similar to:
cd /mnt/c/Users/Username/Desktop
Windows can also access Linux files through File Explorer. In the address bar, the user can enter:
\\wsl$
This opens installed Linux distributions and their file systems. However, for best performance, Linux projects should usually be stored inside the Linux file system rather than on the Windows drive. This is especially true for projects with many small files, such as Node.js applications.
Installing Software in WSL2
WSL2 supports standard Linux package managers. On Ubuntu and Debian, software is usually installed with apt. For example, Git can be installed with:
sudo apt install git
Python, Node.js, build tools, and server software can also be installed. A basic development setup might include:
sudo apt install git curl build-essential python3 python3-pip
This gives the Linux environment common tools for compiling software, downloading files, managing code repositories, and running scripts.
Using WSL2 with Visual Studio Code
WSL2 works especially well with Visual Studio Code. Microsoft provides an extension called Remote Development or WSL that allows VS Code to open folders directly inside the Linux environment. This gives the user a Windows-based editor with Linux-based tools, terminals, and runtime support.
Once the extension is installed, the user can open a WSL terminal, navigate to a project folder, and run:
code .
This launches Visual Studio Code connected to that Linux folder. It is a common workflow for web developers, Python programmers, and cloud engineers.
Running Linux GUI Apps
Modern WSL on Windows 11 supports many Linux graphical applications through a feature commonly called WSLg. This means some Linux GUI applications can run alongside normal Windows apps. For example, a user may install a Linux text editor, file manager, or testing application and launch it from the Linux terminal.
Although WSL2 is most commonly used for command-line work, GUI support makes it more flexible. It is not always a complete replacement for a full Linux desktop, but it is useful for development tools and occasional graphical utilities.
Common Uses for WSL2
WSL2 is useful in many situations. It is especially popular among people who need Linux tools but prefer Windows as their main desktop operating system.
- Web development: Running Node.js, Python, PHP, Ruby, and local servers.
- DevOps: Using SSH, Git, Docker, Kubernetes tools, and cloud CLIs.
- Education: Learning Linux commands without installing Linux separately.
- Cybersecurity labs: Practicing Linux-based security tools in a controlled environment.
- Automation: Running Bash scripts and command-line workflows.
Tips for Using WSL2 Effectively
To get the best experience, users should keep Linux projects inside the Linux home directory, update packages regularly, and use Windows Terminal profiles for quick access. It is also helpful to learn basic Linux commands such as ls, cd, mkdir, cp, mv, and rm.
Another useful habit is shutting down WSL when it is no longer needed. Running wsl --shutdown frees memory and resets the WSL environment. If networking or services behave unexpectedly, restarting WSL often solves the issue.
FAQ
What is WSL2 used for?
WSL2 is used to run Linux environments on Windows 11. It is commonly used for software development, Linux command-line tools, scripting, DevOps work, and learning Linux.
Is WSL2 a full virtual machine?
WSL2 uses lightweight virtualization and a real Linux kernel, but it is not managed like a traditional full virtual machine. It is more integrated with Windows and easier to launch and use.
Is WSL2 free?
Yes. WSL2 is included with Windows 11 and can be installed without additional cost. Most Linux distributions available for WSL are also free.
Which Linux distribution is best for WSL2?
Ubuntu is usually the best starting choice because it is widely supported and has extensive documentation. More advanced users may prefer Debian, Kali Linux, openSUSE, or Fedora Remix.
Can WSL2 run Docker?
Yes. WSL2 works well with Docker Desktop and is commonly used for container-based development on Windows 11.
Can Windows access WSL2 files?
Yes. Windows can access WSL2 files through File Explorer by entering \\wsl$ in the address bar. However, Linux projects generally perform best when stored inside the Linux file system.
Does WSL2 replace installing Linux?
For many command-line and development tasks, WSL2 can replace a separate Linux installation. However, users who need a full Linux desktop experience, direct hardware access, or production-like server behavior may still prefer a full Linux installation or dedicated virtual machine.
How can WSL2 be updated?
WSL can be updated from Windows Terminal by running wsl --update. Linux packages inside the distribution should also be updated using the distribution’s package manager, such as sudo apt update and sudo apt upgrade.