Windows Subsystem for Linux 2 (WSL2) is a powerful feature that allows you to run a full Linux environment directly on your Windows 10 machine. This enables developers, system administrators, and tech enthusiasts to seamlessly switch between Windows and Linux tools without the need for dual-boot setups or separate virtual machines. Installing WSL2 provides improved performance, full Linux kernel support, and compatibility with a wide range of Linux distributions. Before starting, ensure your Windows 10 version supports WSL2 and that your system meets the necessary hardware requirements.
What You’ll Need
- A Windows 10 PC running version 1903 or higher (preferably 1903 or later for better compatibility)
- Admin access to your Windows user account
- Internet connection to download updates and Linux distributions
- Optional: Windows Terminal for an improved terminal experience (recommended)
Step-by-Step
- Check Your Windows Version: Ensure your Windows 10 is version 1903 or higher.
- Press Win + R, type
winver, and press Enter. - If your version is below 1903, update Windows via Settings > Update & Security > Windows Update.
- Press Win + R, type
- Enable the Windows Subsystem for Linux: Open PowerShell as Administrator.
- Right-click the Start menu and select Windows PowerShell (Admin).
- Type the following command and press Enter:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
- Enable the Virtual Machine Platform: Still in PowerShell as Administrator.
- Type the command and press Enter:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
- Type the command and press Enter:
- Restart Your Computer: After enabling both features, restart your PC to apply changes.
- Download and Install the Linux Kernel Update Package: Visit the official Microsoft page to download the latest WSL2 Linux kernel update package.
- Go to: https://aka.ms/wsl2kernel
- Download and run the installer, then follow on-screen instructions.
- Set WSL2 as the Default Version: Open PowerShell as Administrator again.
- Type:
wsl --set-default-version 2
- Type:
- Install a Linux Distribution: Head to the Microsoft Store.
- Search for your preferred Linux distro (e.g., Ubuntu, Debian, Kali Linux).
- Select the distribution and click Install.
- Launch Your Linux Distribution: Once installed, click Launch from the Store or find it in the Start menu.
- The first time you open it, you will be prompted to set up a username and password.
- Optional: Install Windows Terminal: For a better command-line experience, download Windows Terminal from the Microsoft Store.
- Open Windows Terminal, click the dropdown arrow, and select your Linux distribution to start using WSL2 in a modern interface.
Common Mistakes
- Not updating Windows to version 1903 or higher before starting the installation.
- Forgetting to enable both ‘Windows Subsystem for Linux’ and ‘Virtual Machine Platform’ features.
- Not restarting the computer after enabling features, which can prevent WSL2 from functioning properly.
- Installing WSL1 instead of WSL2 because the default is still WSL1; always set WSL2 as default.
- Using an outdated Linux kernel package or ignoring the kernel update step.
Tips
- Keep your Windows updated regularly to ensure compatibility with WSL2 and other features.
- Use Windows Terminal for a more customizable and user-friendly terminal experience.
- Install multiple Linux distributions if needed and manage them with commands like
wsl --list --verbose. - Configure your Linux environment with tools like SSH, Git, and Docker for development workflows.
- Regularly update your Linux packages using commands like
sudo apt update && sudo apt upgrade.
Troubleshooting
If the installation doesn’t go as planned, here are some steps to troubleshoot common issues:
- WSL2 is not set as default: Run
wsl --set-default-version 2in PowerShell. - Linux kernel update fails: Re-download the kernel update package from Microsoft and run it as administrator.
- Feature enabling fails: Ensure you are running PowerShell as administrator and that your Windows version is compatible.
- Linux distribution won’t launch: Try uninstalling and reinstalling the distribution, or reset it via Settings > Apps.
- System cannot find the file specified: Check if virtualization is enabled in your BIOS/UEFI settings, as WSL2 requires hardware virtualization support.
In case of persistent issues, consult the official Microsoft WSL documentation or community forums for detailed support.
Frequently Asked Questions
1. Can I run GUI Linux applications on WSL2?
Yes, with WSLg (Windows Subsystem for Linux GUI), you can run Linux graphical applications seamlessly on Windows 10 and Windows 11.
2. How do I upgrade from WSL1 to WSL2?
Use the command wsl --set-version <DistroName> 2 after installing WSL2 and your distribution.
3. Is WSL2 available on Windows 10 Home edition?
Yes, WSL2 is supported on Windows 10 Home starting from version 2004 and later, with the necessary features enabled.
4. How do I uninstall or reset a Linux distribution?
You can uninstall via Settings > Apps, or reset it using the command wsl --unregister <DistroName> in PowerShell.
5. Can I run Docker inside WSL2?
Absolutely. WSL2 provides excellent support for Docker, and Docker Desktop integrates well with WSL2 for container management.
6. Is WSL2 secure?
WSL2 runs Linux in a lightweight VM, providing strong isolation. However, always keep your system updated and follow best security practices.
By following this guide, you’ll have a fully functional Linux environment on your Windows 10 machine, opening up new possibilities for development and experimentation without leaving your familiar Windows setup.
Related
- How to Hide the Meet Section in Gmail on a Laptop or Desktop
- How to Hide the Mouse Pointer While Typing in Windows 11
- How to Hide the Home Button in Microsoft Edge