Installing WSL 2 on Windows 11
The Windows Subsystem for Linux (WSL) is a powerful tool that allows developers to run a Linux environment directly on Windows without the need for a virtual machine. With WSL 2, you can enjoy a full Linux kernel, enhanced performance, and compatibility with a wide range of Linux applications. Here’s how you can set up WSL 2 on Windows 11. Install WSL | Microsoft Learn
Step 1: Installing WSL
To install WSL, open a Command Prompt or PowerShell terminal with administrative privileges and run the following command:
wsl --install
This command simplifies the installation process by enabling the necessary features and installing a default Linux distribution. Once the command completes, reboot your system to finalize the installation.
Step 2: Verifying the Installation
After rebooting, open Command Prompt or PowerShell and type:
bash
If WSL was successfully installed, this should launch the default Linux distribution. However, in my experience, you might encounter the following error:
Windows Subsystem for Linux has no installed distributions. Use ‘wsl.exe — list — online’ to list available distributions and ‘wsl.exe — install
’ to install. Distributions can also be installed by visiting the Microsoft Store: https://aka.ms/wslstore Error code: Bash/Service/CreateInstance/GetDefaultDistro/WSL_E_DEFAULT_DISTRO_NOT_FOUND This means WSL is installed, but no Linux distribution is set as the default. Don’t worry, we’ll fix that.
Step 3: Listing Available Distributions
To view a list of available Linux distributions, run:
wsl --list --online
This will return a list of distributions you can install. Here’s an example of what you might see:
NAME FRIENDLY NAME Ubuntu Ubuntu Debian Debian GNU/Linux kali-linux Kali Linux Rolling Ubuntu-18.04 Ubuntu 18.04 LTS Ubuntu-20.04 Ubuntu 20.04 LTS Ubuntu-22.04 Ubuntu 22.04 LTS Ubuntu-24.04 Ubuntu 24.04 LTS openSUSE-Tumbleweed openSUSE Tumbleweed
Each entry has a NAME, which is the identifier used in commands, and a FRIENDLY NAME, which gives you a description of the distribution.
Step 4: Installing a Linux Distribution
For this tutorial, I chose Ubuntu 24.04, which is the latest long-term support (LTS) release available. To install it, run:
wsl --install -d Ubuntu-24.04
This command downloads and installs the selected Linux distribution. Once the process is complete, you’ll be prompted to set up your new Linux environment.
Step 5: Setting Up Your Linux Environment
After installation, WSL will automatically launch your chosen distribution for the first time. You’ll be asked to create a username and password for your Linux environment. These credentials are independent of your Windows account and are used to manage your Linux system.
Troubleshooting Tips
- Error: WSL version not set to WSL 2
If you encounter issues where WSL 2 isn’t the default version, you can set it manually by running:
wsl --set-default-version 2
- Installing Additional Distributions
If you’d like to install additional distributions, you can repeat the wsl –install -d
- Managing Installed Distributions
To view all installed distributions, use:
wsl --list --verbose
- This will show the installed distributions along with their version (WSL 1 or WSL 2) and their current state.
- Switching Between Distributions
If you have multiple distributions installed, you can launch a specific one by typing:
wsl -d <Distro>
Conclusion
Installing WSL 2 on Windows 11 provides a seamless way to run Linux alongside Windows. Whether you’re a developer, a student, or a Linux enthusiast, WSL 2 makes it easier than ever to leverage the power of Linux tools and workflows directly from your Windows machine — or in my case, my Windows VM running on my MacBook Pro!
Enjoy exploring the Linux ecosystem! If you have any questions or run into issues, feel free to reach out or check out the official WSL documentation.