Windows Subsystem for Linux (WSL) allows you to run a Linux environment directly on your Windows machine without the need for virtual machines. This guide will walk you through the process of installing and enabling WSL on your local machine and installing Ubuntu 22.04 LTS.
Prerequisites
Before proceeding, ensure that your PC meets the following requirements:
- Windows 10 Version 1903 (or later)
- Build 18362 (or later)
Enabling WSL
Open the Start menu and search for “PowerShell”.
Right-click on Windows PowerShell and select “Run as administrator”.
Execute the following command to enable WSL:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Execute the following command to enable the “Windows Virtual Machine Platform”:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Restart your PC for the changes to take effect.
Installing the Linux Kernel Update Package
Download the Linux kernel update package from Microsoft’s website.
Execute the downloaded file to start the installation and follow the on-screen instructions.
Setting WSL 2 as Default
Open PowerShell as administrator.
Execute the following command to set WSL 2 as the default version:
wsl --set-default-version 2
Installing a Linux Distribution
Choose the Linux distribution you want to install from the following list:
Linux Distribution | Installation via MS Store | Installation via CLI |
---|---|---|
Ubuntu 16.04 | No | Yes |
Ubuntu 18.04 | No | Yes |
Ubuntu 18.04 ARM | No | Yes |
Ubuntu 18.04 LTS | Yes | No |
Ubuntu 20.04 | No | Yes |
Ubuntu 20.04 ARM | No | Yes |
Ubuntu 20.04 LTS | Yes | No |
Ubuntu 22.04 LTS | Yes | Yes |
Debian GNU/Linux | Yes | Yes |
OpenSUSE Leap 15.1 | Yes | No |
OpenSUSE Leap 15.2 | No | Yes |
OpenSUSE Leap 15.3 | No | Yes |
OpenSUSE Tumbleweed | No | Yes |
SUSE Linux Enterprise Server 12 | No | Yes |
SUSE Linux Enterprise Server 12 SP5 | Yes | No |
SUSE Linux Enterprise Server 15 SP1 | Yes | No |
SUSE Linux Enterprise Server 15 SP2 | No | Yes |
SUSE Linux Enterprise Server 15 SP3 | No | Yes |
Kali Linux | Yes | Yes |
Fedora Remix for WSL | Yes | Yes |
Pengwin | Yes | No |
Pengwin Enterprise | Yes | No |
Alpine WSL | Yes | No |
Raft (Free Trial) | Yes | No |
Oracle Linux 7.9 | No | Yes |
Oracle Linux 8.5 | No | Yes |
Installing via Microsoft Store
a. Access the Microsoft Store for the selected Linux distribution.
b. Click on the “Get” button to initiate the installation.
c. Open the newly installed Linux distribution from the Start menu.
d. Create a username and password for your Linux instance.
Installing via Command Line Interface (CLI)
a. Open PowerShell as administrator.
b. Obtain the download link for the selected Linux distribution from Microsoft’s documentation.
c. Execute the following command to download the Linux distribution:
curl.exe -L -o ubuntu-2004.appx [link_to_your_linux_distro]
d. Execute the following command to add the Appx-Package:
Add-AppxPackage .\app_name.appx
e. Double-click the downloaded Appx-Package file to install it.
f. Click on the “Install” button.
g. Launch the newly installed Linux distribution.
h. Create a username and password for your Linux
Conclusion
By following the steps outlined in this guide, you can effectively install and configure Windows Subsystem for Linux 2 on your Microsoft Windows 10 machine. With WSL, you can seamlessly integrate Linux environments into your Windows workflow, expanding your development and productivity capabilities.