Introduction
In this article, I will explain how we can install Windows Subsystem for Linux (WSL2) on windows 11.
Windows Subsystem for Linux
Microsoft's Windows Subsystem For Linux (WSL) is a technology that allows Linux to operate natively on Windows. It's intended to be a seamless experience, offering a full Linux shell that can interact with your Windows disc.
WSL allows you to install a whole Linux distribution from the app store as an app. Simply download Ubuntu (or your preferred distribution), install it, and have it ready as a launchable program or a profile in your terminal to run alongside CMD or Powershell. WSL is designed to provide developers and bash veterans with the Linux shell experience despite the fact that Windows is the primary operating system. It combines the best of both worlds by letting you run Windows applications like Visual Studio with a Linux shell for quicker command-line access.
Why use Windows Subsystem for Linux
WSL requires fewer resources (CPU, memory, and storage) than a full virtual machine. WSL also allows you to run Linux command-line tools and apps alongside your Windows command-line, desktop, and store apps, and to access your Windows files from within Linux. This enables you to use Windows apps and Linux command-line tools on the same set of files if you wish.
WSL 1 vs WSL 2
WSL is available from Microsoft in two versions: version 1 and version 2. WSL 2 runs on a virtual machine and makes use of a full Linux kernel that is produced and distributed with Windows. WSL 1 is older and typically slower, but it performs better when working across filesystems, such as reading Windows files from Linux and vice versa. WSL 2 is our recommendation for most operations because it is quicker and works much better with technologies like Docker.
Feature |
WSL 1 |
WSL 2 |
Integration between Windows and Linux |
Yes |
Yes |
Fast boot times |
Yes |
Yes |
Small resource footprint compared to traditional Virtual Machines |
Yes |
Yes |
Runs with current versions of VMware and VirtualBox |
Yes |
Yes |
Managed VM |
No |
Yes |
Full Linux Kernel |
No |
Yes |
Full system call compatibility |
No |
Yes |
Performance across OS file systems |
Yes |
No |
Install WSL2
Step 1
Open Command Prompt as administrator. Or you can open Windows Powershell.
Step 2
Execute the following command
wsl --install
Step 3
Restart your computer to finish installation on Windows 11.
Step 4
Continue with Ubuntu distro setup as necessary.
Install WSL2 with specific distro on Windows 11
Step 1
Open Command Prompt as administrator. Or you can open Windows Powershell.
Step 2
Execute the following command to list the available distros.
wsl --list --online
Step 3
Type the following command to install the WSL with a specific distro on Windows 11 and press Enter
wsl --install -d DISTRO-NAME
-
Ubuntu – Allows one to use Ubuntu Terminal and run Ubuntu command line utilities including bash, ssh, git, apt, and many more.
-
Debian GNU/Linux – A complete Debian command-line environment for the current stable release
-
Kali – An open-source penetration testing and ethical hacking distribution.
-
openSUSE Leap 42 – A stable, easy to use, and complete multi-purpose Linux distribution.
-
SUSE Linux Enterprise Server 12 (SLES) – A world-class, secure open-source server operating system, built to power physical, virtual and cloud-based mission-critical workloads.
For example:
wsl --install -d Ubuntu-20.04
Step 3
Restart your computer to finish installation on Windows 11.
Step 4
Continue with ubuntu distro setup as necessary. After you complete all the steps, the Windows Subsystem for Linux 2 components will install along with the distro of Linux you specified.
Install WSL2 from Microsoft Store
To install WSL2 from the store, you need to check if the "Virtual Machine Platform" platform is on or off, to check that please follow the steps:
1. Open Start.
2. Search for Turn Windows Features on or off and click the top result to open the page.
3. Check the Virtual Machine Platform option.
4. Click the OK button.
5. Click the Restart button.
After we are done enabling the "Virtual Machine Platform" feature, we can go to the Microsoft Store.
1. Open the Store App from the start menu.
2. Search for the Distro name you want to install. I want to install "Ubuntu 18"
3. Click the Install button.
4. After the install process completes, you will see a start menu shortcut for Ubuntu 18.04 LTS.
Useful Commands
Update WSL |
wsl --update |
Install WSL |
wsl --install |
Install a specific Linux Distribution |
wsl --install --distribution <Distribution Name> or wsl --install -d <Distribution Name> |
List all available Distribution |
wsl --list --online |
List all installed Distributions |
wsl --list --verbose |
Set WSL version from 1 to 2 |
wsl --set-version <distribution name> <versionNumber> |
Set default WSL version |
wsl --set-default-version <Version> |
Set default Linux distribution |
wsl --set-default <Distribution Name> |
Change directory to home |
wsl ~ |
Run a specific Linux distribution from PowerShell or CMD |
wsl --distribution <Distribution Name> --user <User Name> |
Check WSL status |
wsl --status |
List of options and commands available with WSL |
wsl --help |
Run as a specific user |
wsl -u <Username>`, `wsl --user <Username> |
Change the default user for a distribution |
<DistributionName> config --default-user <Username> |
To shutdown WSL |
wsl --shutdown |
To terminate or stop from running a specific distribution |
wsl --terminate <Distribution Name> |
Export a distribution to a TAR file |
wsl --export <Distribution Name> <FileName> |
Import a new distribution |
wsl --import <Distribution Name> <InstallLocation> <FileName> |
Unregister or uninstall a Linux distribution |
wsl --unregister <DistributionName> |
Mount a disk or device |
wsl --mount <DiskPath> |
Conclusion
In this article, we discussed how we can install WSL2 on Windows 11.
Visit C# Corner to find answers to more such questions.
If you have any questions regarding any other technology do have a look at the C# Corner Technology Page.