How to Enable Windows Subsystem for Linux (WSL) on Windows Server 2022
Windows Subsystem for Linux (WSL) allows you to run Linux distributions natively on your Windows Server environment, enabling developers and IT professionals to use Linux tools and workflows seamlessly. While enabling WSL on Windows Server 2022 is slightly different from enabling it on Windows 10 or 11, the process is straightforward. This guide will walk you through the steps to enable WSL and install a Linux distribution on Windows Server 2022.
Prerequisites
Before proceeding, ensure that:
You are running Windows Server 2022.
You have administrator privileges.
The server has an active internet connection.
Step 1: Install the Required Features
WSL requires specific Windows features to be enabled. To install these features, follow these steps:
Using PowerShell
Open PowerShell as an administrator.
Run the following command to enable the necessary features:
Step 3: Set WSL 2 as the Default Version (Optional)
WSL 2 offers better performance and full system call compatibility. To set WSL 2 as the default version, use the following command:
wsl --set-default-version 2
If you encounter an error indicating that your hardware does not support WSL 2, ensure that virtualization is enabled in your server’s BIOS/UEFI settings.
Step 4: Install a Linux Distribution
With WSL enabled, you can now install a Linux distribution:
Open PowerShell as an administrator.
List available distributions by running:
wsl --list --online
Install your preferred distribution (e.g., Ubuntu):
wsl --install -d Ubuntu
Wait for the installation to complete. Once finished, the Linux distribution will launch, and you will be prompted to create a user account.
Step 5: Verify the Installation
To confirm that WSL is installed and working:
Open PowerShell.
Run the following command:
wsl --list --verbose
This will display the installed distributions and their WSL version.
Launch the Linux distribution by typing its name in PowerShell (e.g., ubuntu).
Additional Configuration
Accessing Files: You can access your Windows files from the Linux distribution under the /mnt directory (e.g., /mnt/c/ for the C:\ drive).
Updating the Distribution: Keep your Linux distribution updated using the package manager (e.g., sudo apt update && sudo apt upgrade for Ubuntu).
Uninstalling a Distribution: To uninstall a distribution, run:
wsl --uninstall -d <DistributionName>
Conclusion
Enabling WSL on Windows Server 2022 allows you to leverage the power of Linux tools directly within your server environment. Whether you are a developer or an IT professional, WSL provides a seamless way to integrate Windows and Linux workflows. By following the steps in this guide, you’ll have WSL up and running in no time.
Enable Windows Subsystem for Linux (WSL) on Windows Server 2022 (F.A.Q)
Can I enable WSL on Windows Server 2022 Core?
Yes, WSL can be enabled on both the Desktop Experience and Core installations of Windows Server 2022 using PowerShell.
What are the hardware requirements for WSL 2?
WSL 2 requires a machine with virtualization enabled. Ensure that your server’s BIOS/UEFI has virtualization support turned on.
How do I switch between WSL 1 and WSL 2 for a distribution?
You can switch using the command:
wsl --set-version <DistributionName> <Version>
Replace <DistributionName> with your distribution’s name and <Version> with 1 or 2.
Is it possible to run GUI applications on WSL?
Yes, with WSLg (Windows Subsystem for Linux GUI), you can run Linux GUI applications on Windows Server 2022. Ensure you have WSL 2 and the latest updates installed.