Introduction
Windows Subsystem for Linux (WSL) allows you to run a Linux environment directly on Windows without needing a virtual machine or dual-boot setup. This guide will walk you through installing and setting up Ubuntu on WSL.
Prerequisites
-
A Windows 10 (Version 2004 or later) or Windows 11 machine
-
Administrator privileges
-
Internet connection
Step 1: Enable WSL
Method 1: Using PowerShell
-
Open PowerShell as Administrator.
-
Run the following command to enable WSL:
wsl --install
This command will:
-
Enable the WSL feature
-
Install the default Linux distribution (usually Ubuntu)
-
Set up necessary system components
-
-
Restart your computer when prompted.
Method 2: Manual Installation (For Older Versions)
If the above command doesn’t work, follow these steps:
-
Open PowerShell as Administrator.
-
Enable the required features manually:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
-
Restart your computer.
-
Install the WSL 2 Linux kernel update from Microsoft’s official website.
-
Set WSL 2 as the default version:
wsl --set-default-version 2
Step 2: Install Ubuntu
-
Open Microsoft Store.
-
Search for Ubuntu.
-
Click Install on your preferred Ubuntu version (e.g., Ubuntu 22.04 LTS).
-
Once installed, launch Ubuntu from the Start menu.
Troubleshooting
1. "WSL 2 requires a kernel update"
-
Download and install the WSL 2 kernel update from here.
2. "Ubuntu is not launching"
-
Try restarting WSL:
wsl --shutdown
-
Then relaunch Ubuntu.
3. Switching to WSL 2 manually
If Ubuntu is using WSL 1, upgrade it:
Conclusion
You have successfully installed and configured Ubuntu on WSL! You can now run Linux commands, develop applications, and integrate Ubuntu seamlessly with Windows.